---
title: "CFHTTPMessageCreateResponse(_:_:_:_:)"
framework: cfnetwork
role: symbol
role_heading: Function
path: "cfnetwork/cfhttpmessagecreateresponse(_:_:_:_:)"
---

# CFHTTPMessageCreateResponse(_:_:_:_:)

Creates and returns a CFHTTPMessage object for an HTTP response.

## Declaration

```swift
func CFHTTPMessageCreateResponse(_ alloc: CFAllocator?, _ statusCode: CFIndex, _ statusDescription: CFString?, _ httpVersion: CFString) -> Unmanaged<CFHTTPMessage>
```

## Parameters

- `statusCode`: The status code for this message response. The status code can be any of the status codes defined in section 6.1.1 of RFC 2616.
- `statusDescription`: The description that corresponds to the status code. Pass NULL to use the standard description for the given status code, as found in RFC 2616.
- `httpVersion`: The HTTP version for this message response. 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 response. Continue building the response by callingCFHTTPMessageSetBody(_:_:) to set the message’s body. Call CFHTTPMessageSetHeaderFieldValue(_:_:_:) to set the message’s headers. Then 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)
