Core Foundation等同于NSURLRequest和NSURLConnection [英] Core Foundation equivalents for NSURLRequest and NSURLConnection

查看:266
本文介绍了Core Foundation等同于NSURLRequest和NSURLConnection的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道NSUrl桥接到CFUrl。对于 NSURLRequest NSURLConnection 来说,我可以用CFUrl对象使用纯C? / p>

I'm aware that NSUrl is bridged to CFUrl. What are the Core Foundation equivalents for NSURLRequest and NSURLConnection so I can do something with a CFUrl object using pure C?

推荐答案

不能直接等同于 NSURLRequest NSURLConnection 在Core Foundation中,但您可以在 CFNetwork

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

例如,

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);

这篇关于Core Foundation等同于NSURLRequest和NSURLConnection的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆