---
title: "CFReadStreamCreateForHTTPRequest(_:_:)"
framework: cfnetwork
role: symbol
role_heading: Function
path: "cfnetwork/cfreadstreamcreateforhttprequest(_:_:)"
---

# CFReadStreamCreateForHTTPRequest(_:_:)

Creates a read stream for a CFHTTP request message.

## Declaration

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

Return Value A new read stream, or NULL if there was a problem creating the object. Ownership follows the The Create Rule.

## Discussion

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 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 CFReadStreamOpen(_:). If the body of the request is too long to keep in memory, call CFReadStreamCreateForStreamedHTTPRequest(_:_:_:) instead of this function.

## See Also

### Streams

- [CFReadStreamCreateForStreamedHTTPRequest(_:_:_:)](cfnetwork/cfreadstreamcreateforstreamedhttprequest(_:_:_:).md)
- [kCFStreamPropertyHTTPAttemptPersistentConnection](cfnetwork/kcfstreampropertyhttpattemptpersistentconnection.md)
- [kCFStreamPropertyHTTPFinalRequest](cfnetwork/kcfstreampropertyhttpfinalrequest.md)
- [kCFStreamPropertyHTTPFinalURL](cfnetwork/kcfstreampropertyhttpfinalurl.md)
- [kCFStreamPropertyHTTPProxy](cfnetwork/kcfstreampropertyhttpproxy.md)
- [kCFStreamPropertyHTTPProxyHost](cfnetwork/kcfstreampropertyhttpproxyhost.md)
- [kCFStreamPropertyHTTPProxyPort](cfnetwork/kcfstreampropertyhttpproxyport.md)
- [kCFStreamPropertyHTTPRequestBytesWrittenCount](cfnetwork/kcfstreampropertyhttprequestbyteswrittencount.md)
- [kCFStreamPropertyHTTPResponseHeader](cfnetwork/kcfstreampropertyhttpresponseheader.md)
- [kCFStreamPropertyHTTPSProxyHost](cfnetwork/kcfstreampropertyhttpsproxyhost.md)
- [kCFStreamPropertyHTTPSProxyPort](cfnetwork/kcfstreampropertyhttpsproxyport.md)
- [kCFStreamPropertyHTTPShouldAutoredirect](cfnetwork/kcfstreampropertyhttpshouldautoredirect.md)
- [CFWriteStreamCreateWithFTPURL(_:_:)](cfnetwork/cfwritestreamcreatewithftpurl(_:_:).md)
- [CFReadStreamCreateWithFTPURL(_:_:)](cfnetwork/cfreadstreamcreatewithftpurl(_:_:).md)
- [kCFStreamPropertyFTPAttemptPersistentConnection](cfnetwork/kcfstreampropertyftpattemptpersistentconnection.md)
