Contents

CFHTTPMessageCreateRequest(_:_:_:_:)

Creates and returns a CFHTTPMessage object for an HTTP request.

Declaration

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.

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