Function

CFHTTPMessageCreateRequest

Creates and returns a CFHTTPMessage object for an HTTP request.

Declaration

CFHTTPMessageRef CFHTTPMessageCreateRequest(CFAllocatorRef alloc, CFStringRef requestMethod, CFURLRef url, CFStringRef httpVersion);

Parameters

allocator

The allocator to use to allocate memory for the new object. Pass NULL or kCFAllocatorDefault to use the current default allocator.

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.

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

CFHTTPMessageRef

An opaque reference representing an HTTP message.

CFHTTPMessageAddAuthentication

Adds authentication information to a request.

CFHTTPMessageAppendBytes

Appends data to a CFHTTPMessage object.

CFHTTPMessageApplyCredentialDictionary

Use a dictionary containing authentication credentials to perform the authentication method specified by a CFHTTPAuthentication object.

CFHTTPMessageApplyCredentials

Performs the authentication method specified by a CFHTTPAuthentication object.

CFHTTPMessageCopyAllHeaderFields

Gets all header fields from a CFHTTPMessage object.

CFHTTPMessageCopyBody

Gets the body from a CFHTTPMessage object.

CFHTTPMessageCopyHeaderFieldValue

Gets the value of a header field from a CFHTTPMessage object.

CFHTTPMessageCopyRequestMethod

Gets the request method from a CFHTTPMessage object.

CFHTTPMessageCopyRequestURL

Gets the URL from a CFHTTPMessage object.

CFHTTPMessageCopyResponseStatusLine

Gets the status line from a CFHTTPMessage object.

CFHTTPMessageCopySerializedMessage

Serializes a CFHTTPMessage object.

CFHTTPMessageCopyVersion

Gets the HTTP version from a CFHTTPMessage object.

CFHTTPMessageCreateCopy

Gets a copy of a CFHTTPMessage object.

CFHTTPMessageCreateEmpty

Creates and returns a new, empty CFHTTPMessage object.

CFHTTPMessageCreateResponse

Creates and returns a CFHTTPMessage object for an HTTP response.

CFHTTPMessageGetResponseStatusCode

Gets the status code from a CFHTTPMessage object representing an HTTP response.

CFHTTPMessageGetTypeID

Returns the Core Foundation type identifier for the CFHTTPMessage opaque type.

CFHTTPMessageIsHeaderComplete

Determines whether a message header is complete.

CFHTTPMessageIsRequest

Returns a Boolean indicating whether the HTTP message is a request or a response.

CFHTTPMessageSetBody

Sets the body of a CFHTTPMessage object.

CFHTTPMessageSetHeaderFieldValue

Sets the value of a header field in an HTTP message.

kCFHTTPVersion1_0

Specifies HTTP version 1.0.

kCFHTTPVersion1_1

Specifies HTTP version 1.1.