What is replacement of CFReadStreamCreateForStreamedHTTPRequest?

五迷三道 提交于 2019-12-02 19:33:01

问题


In my objective C project i am using

  • Segment 1).
[(NSInputStream *)CFReadStreamCreateForStreamedHTTPRequest(kCFAllocatorDefault, request,(CFReadStreamRef)[self postBodyReadStream]) autorelease]

but CFReadStreamCreateForStreamedHTTPRequest is deprecated what can i write alternatively ?

I tried

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request

Error throws:-

Incompatible pointer types sending 'CFHTTPMessageRef' (aka 'struct >__CFHTTPMessage *') to parameter of type 'NSURLRequest * _Nonnull'

  • Segment 2).
(NSString *)kCFStreamPropertyHTTPProxyHost

'kCFStreamPropertyHTTPProxyHost' is deprecated: Haven't found any replacement API.


回答1:


To use dataTaskWithRequest:, you need to create an NSURLRequest, not a CFHTTPMessageRef.

As for kCFStreamPropertyHTTPProxyHost, this question asks “How to programmatically add a proxy to an NSURLSession” and has an answer that looks good to me.



来源:https://stackoverflow.com/questions/57195022/what-is-replacement-of-cfreadstreamcreateforstreamedhttprequest

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!