问题描述
这是我今天提出的一个非常简单的问题.是否可以将特定的HTTP协议版本设置为 NSURLRequest
对象(例如1.0或1.1)?
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)?
我在telnet上谈论的一个例子:
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
推荐答案
您不能更改 NSURLRequest
的HTTP版本.但是,您可以使用 CFNetwork
框架.这是 NSURLConnection
所基于的C框架.
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.
CFHTTPMessageCreateRequest
函数创建具有任意HTTP协议版本的新消息.然后,该消息可用于使用 CFReadStreamCreateForHTTPRequest
函数创建输入流.
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.
这篇关于NSURLRequest http协议版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!