<!--
{
  "availability" : [
    "iOS: 2.0.0 - 9.0.0",
    "iPadOS: 2.0.0 - 9.0.0",
    "macCatalyst: 13.1.0 - 13.1.0",
    "macOS: 10.2.0 - 10.11.0",
    "tvOS: 9.0.0 - 9.0.0",
    "visionOS: 1.0.0 - 1.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "CFNetwork",
  "identifier" : "/documentation/CFNetwork/CFReadStreamCreateForHTTPRequest(_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "CFNetwork"
    ],
    "preciseIdentifier" : "c:@F@CFReadStreamCreateForHTTPRequest"
  },
  "title" : "CFReadStreamCreateForHTTPRequest(_:_:)"
}
-->

# CFReadStreamCreateForHTTPRequest(_:_:)

Creates a read stream for a CFHTTP request message.

```
func CFReadStreamCreateForHTTPRequest(_ alloc: CFAllocator?, _ request: CFHTTPMessage) -> Unmanaged<CFReadStream>
```

## Parameters

`alloc`

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

`request`

A CFHTTP request message whose body and headers have been set.

## Return Value

A new read stream, 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 creates a read stream and associates it with the specified request. Automatic redirection is disabled by default. After creating the read stream, you can call <doc://com.apple.documentation/documentation/CoreFoundation/CFReadStreamGetError(_:)> at any time to check the status of the stream. You may want to call `CFHTTPReadStreamSetRedirectsAutomatically` to enable automatic redirection, or `CFHTTPReadStreamSetProxy` to set the name and port number for a proxy. To serialize the request and send it, call <doc://com.apple.documentation/documentation/CoreFoundation/CFReadStreamOpen(_:)>.

If the body of the request is too long to keep in memory, call [`CFReadStreamCreateForStreamedHTTPRequest(_:_:_:)`](/documentation/CFNetwork/CFReadStreamCreateForStreamedHTTPRequest(_:_:_:)) instead of this function.

---

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)