NSURLRequest http协议版本 [英] NSURLRequest http protocol version

查看:70
本文介绍了NSURLRequest http协议版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我今天提出的一个非常简单的问题.是否可以将特定的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.

文档: 查看全文

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