views:

78

answers:

3

Ok so I've been reading up on HTTP and found this page. This is an example HTTP request that was posted there:

GET /http.html Http1.1
Host: www.http.header.free.fr
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
Accept-Language: Fr
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 4.0)
Connection: Keep-Alive

I tried it in telnet and it worked. But everywhere else I see this kind of request line

GET /http.html HTTP/1.1

The important different is that HTTP is all caps and the / character.

Are they both correct? They both seem to work on the sites I've tested it on. I've skimmed the RFC of HTTP but didn't find anything of use. Has anyone else seen this kind of request header? Is it officially supported?

+3  A: 

Refering to the HTTP protocol, it must be in HTTP/1.1 or HTTP/1.0 (older one). Now it depend how the http server was developed. It may accept it but you should not rely on it.

EDIT:

HTTP-Version = "HTTP" "/" 1*DIGIT "." 1*DIGIT

And now the protocol is 1.1 so you should use: GET /http.html HTTP/1.1

Phong
A: 

It should be

GET /http.html HTTP/1.1
Misk
+1  A: 

According to RFC2145 (page 3),

RFC791 [4] defines the "robustness principle" in section 3.2:

an implementation must be conservative in its sending behavior, and liberal in its receiving behavior.

This principle applies to HTTP, as well. It is the fundamental basis for interpreting any part of the HTTP specification that might still be ambiguous. In particular, implementations of HTTP SHOULD NOT reject messages or generate errors unnecessarily.

And in particular:

It is, and has always been, the explicit intent of the HTTP specification that an implementation receiving a message header that it does not understand MUST ignore that header.

So the server is ignoring the version number in the case that it's "Http1.1" (which is not valid) and presumably it's interpreting the message as a HTTP/1.0 message (or maybe even HTTP/0.9!). Of course, you should not rely on this behaviour!

Dean Harding