<!--
{
  "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/CFHTTPMessageCreateResponse(_:_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "CFNetwork"
    ],
    "preciseIdentifier" : "c:@F@CFHTTPMessageCreateResponse"
  },
  "title" : "CFHTTPMessageCreateResponse(_:_:_:_:)"
}
-->

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

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

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

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 response. Continue building the response by calling[`CFHTTPMessageSetBody(_:_:)`](/documentation/CFNetwork/CFHTTPMessageSetBody(_:_:)) to set the message’s body. Call [`CFHTTPMessageSetHeaderFieldValue(_:_:_:)`](/documentation/CFNetwork/CFHTTPMessageSetHeaderFieldValue(_:_:_:)) to set the message’s headers. Then 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)