NSURLRequest http protocol version

自古美人都是妖i 提交于 2019-12-10 21:21:02

问题


It is quite a simple question from me today. Is it possible to set specific HTTP protocol version to NSURLRequest object (1.0 or 1.1, for example)?

An example of what I'm talking about on telnet:

pavlov:~ pavlov$ telnet ya.ru 80
Trying 87.250.250.3...
Connected to ya.ru.
Escape character is '^]'.
GET /index.php HTTP/1.0

回答1:


You cannot change the HTTP version of a NSURLRequest. However you can use the CFNetwork framework. It's the C framework on top of which NSURLConnection is based.

The CFHTTPMessageCreateRequest function creates a new message with an arbitrary HTTP protocol version. Then, that message may be used to create an input stream using the CFReadStreamCreateForHTTPRequest function.

Documentation: CFNetwork - Communicating with HTTP Servers



来源:https://stackoverflow.com/questions/9312669/nsurlrequest-http-protocol-version

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