4

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
basvk
  • 4,437
  • 3
  • 29
  • 49
Valerii Pavlov
  • 1,986
  • 1
  • 19
  • 30
  • Good question, I see that you can set header values us NSMutableURLRequest but version isn't a header. There's also a method propertyForKey:inRequest: that might give you the version option? – rooftop Feb 16 '12 at 15:23

1 Answers1

2

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

Nicolas Bachschmidt
  • 6,475
  • 2
  • 26
  • 36