Core equivalents for NSURLRequest and NSURLConnection

I know that NSUrl is connected to CFUrl. What are the Core Foundation equivalents for NSURLRequestand NSURLConnectionso I can do something with a CFUrl object using pure C?

+3
source share
1 answer

There are no direct equivalents to the Core Foundation NSURLRequestand NSURLConnection, but you can use the lower-level CFHTTP functions in CFNetwork .

For instance,

CFHTTPMessageRef myRequest = CFHTTPMessageCreateRequest(kCFAllocatorDefault,
        requestMethod, myUrl, kCFHTTPVersion1_1);
CFHTTPMessageSetBody(myRequest, bodyData);
CFHTTPMessageSetHeaderFieldValue(myRequest, headerField, value);

CFReadStreamRef myReadStream = CFReadStreamCreateForHTTPRequest(kCFAllocatorDefault, myRequest);

CFReadStreamOpen(myReadStream);

CFHTTPMessageRef myResponse = CFReadStreamCopyProperty(myReadStream, kCFStreamPropertyHTTPResponseHeader);
+5
source

Source: https://habr.com/ru/post/1746094/


All Articles