---
title: "CFHTTPMessageCreateRequest(_:_:_:_:)"
framework: cfnetwork
role: symbol
role_heading: Function
path: "cfnetwork/cfhttpmessagecreaterequest(_:_:_:_:)"
---

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

Creates and returns a CFHTTPMessage object for an HTTP request.

## Declaration

```swift
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

Return Value A new CFHTTPMessage object, or NULL if there was a problem creating the object. Ownership follows the The Create Rule.

## Discussion

Discussion This function returns a CFHTTPMessage object that you can use to build an HTTP request. Continue building the request by callingCFHTTPMessageSetBody(_:_:) to set the message’s body. Call CFHTTPMessageCopyHeaderFieldValue(_:_:) to set the message’s headers. If you are using a CFReadStream object to send the message, call CFReadStreamCreateForHTTPRequest(_:_:) to create a read stream for the request. If you are not using CFReadStream, call CFHTTPMessageCopySerializedMessage(_:) to make the message ready for transmission by serializing it.

## See Also

### HTTP Messages

- [CFHTTPMessage](cfnetwork/cfhttpmessage.md)
- [CFHTTPMessageAddAuthentication(_:_:_:_:_:_:)](cfnetwork/cfhttpmessageaddauthentication(_:_:_:_:_:_:).md)
- [CFHTTPMessageAppendBytes(_:_:_:)](cfnetwork/cfhttpmessageappendbytes(_:_:_:).md)
- [CFHTTPMessageApplyCredentialDictionary(_:_:_:_:)](cfnetwork/cfhttpmessageapplycredentialdictionary(_:_:_:_:).md)
- [CFHTTPMessageApplyCredentials(_:_:_:_:_:)](cfnetwork/cfhttpmessageapplycredentials(_:_:_:_:_:).md)
- [CFHTTPMessageCopyAllHeaderFields(_:)](cfnetwork/cfhttpmessagecopyallheaderfields(_:).md)
- [CFHTTPMessageCopyBody(_:)](cfnetwork/cfhttpmessagecopybody(_:).md)
- [CFHTTPMessageCopyHeaderFieldValue(_:_:)](cfnetwork/cfhttpmessagecopyheaderfieldvalue(_:_:).md)
- [CFHTTPMessageCopyRequestMethod(_:)](cfnetwork/cfhttpmessagecopyrequestmethod(_:).md)
- [CFHTTPMessageCopyRequestURL(_:)](cfnetwork/cfhttpmessagecopyrequesturl(_:).md)
- [CFHTTPMessageCopyResponseStatusLine(_:)](cfnetwork/cfhttpmessagecopyresponsestatusline(_:).md)
- [CFHTTPMessageCopySerializedMessage(_:)](cfnetwork/cfhttpmessagecopyserializedmessage(_:).md)
- [CFHTTPMessageCopyVersion(_:)](cfnetwork/cfhttpmessagecopyversion(_:).md)
- [CFHTTPMessageCreateCopy(_:_:)](cfnetwork/cfhttpmessagecreatecopy(_:_:).md)
- [CFHTTPMessageCreateEmpty(_:_:)](cfnetwork/cfhttpmessagecreateempty(_:_:).md)
