<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.1.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CFNetwork",
  "identifier" : "/documentation/CFNetwork/CFHTTPMessageCreateRequest(_:_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "CFNetwork"
    ],
    "preciseIdentifier" : "c:@F@CFHTTPMessageCreateRequest"
  },
  "title" : "CFHTTPMessageCreateRequest(_:_:_:_:)"
}
-->

# CFHTTPMessageCreateRequest(_:_:_:_:)

Creates and returns a `CFHTTPMessage` object for an HTTP request.

```
func CFHTTPMessageCreateRequest(_ alloc: CFAllocator?, _ requestMethod: CFString, _ url: CFURL, _ httpVersion: CFString) -> Unmanaged<CFHTTPMessage>
```

## Parameters

`requestMethod`

The request method for the request. Use any of the request methods allowed by the HTTP version specified by `httpVersion`.

`url`

The URL to which the request will be sent.

`httpVersion`

The HTTP version for this message. Pass `kCFHTTPVersion1_0` or `kCFHTTPVersion1_1`.

## Return Value

A new `CFHTTPMessage` object, or `NULL` if there was a problem creating the object. Ownership follows the [The Create Rule](https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFMemoryMgmt/Concepts/Ownership.html#//apple_ref/doc/uid/20001148-103029).

## Discussion

This function returns a `CFHTTPMessage` object that you can use to build an HTTP request. Continue building the request by calling[`CFHTTPMessageSetBody(_:_:)`](/documentation/CFNetwork/CFHTTPMessageSetBody(_:_:)) to set the message’s body. Call [`CFHTTPMessageCopyHeaderFieldValue(_:_:)`](/documentation/CFNetwork/CFHTTPMessageCopyHeaderFieldValue(_:_:)) to set the message’s headers.

If you are using a `CFReadStream` object to send the message, call [`CFReadStreamCreateForHTTPRequest(_:_:)`](/documentation/CFNetwork/CFReadStreamCreateForHTTPRequest(_:_:)) to create a read stream for the request. If you are not using `CFReadStream`, call [`CFHTTPMessageCopySerializedMessage(_:)`](/documentation/CFNetwork/CFHTTPMessageCopySerializedMessage(_:)) to make the message ready for transmission by serializing it.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)