1

I've researched a bit to find out that the Status line is the the start line of an HTTP response. It contains the information such as the protocol version, a status text, status code. But why does it have to contain the protocol version again?

1
  • mostly to verify the protocol. Non-http servers 9may respond to an HTTP message, likely with a number Aug 3, 2019 at 2:14

1 Answer 1

1

The HTTP version numbers are present in the request and response for HTTP/1.0 and 1.1. (HTTP/2 is quite different. When using a browser, the protocol is negotiated by the TLS connection wrapped around HTTP.)

RFC 2145 says,

An HTTP server SHOULD send a response version equal to the highest version for which the server is at least conditionally compliant, and whose major version is less than or equal to the one received in the request. An HTTP server MUST NOT send a version for which it is not at least conditionally compliant. A server MAY send a 505 (HTTP Version Not Supported) response if cannot send a response using the major version used in the client's request.

This means a server compatible with HTTP/1.1 should respond with HTTP/1.1 to both, HTTP/1.1 and HTTP/1.0 requests. A server supporting only HTTP/1.0, could respond to HTTP/1.1 request with HTTP/1.0 responses.

For example, if you send a HTTP/1.0 request to wikipedia.org,

$ nc wikipedia.org 80
GET / HTTP/1.0

HTTP/1.1 400 
Date: Mon, 05 Aug 2019 18:03:20 GMT
Server: Varnish
...

the server responds with HTTP/1.1 (although with an error).

So the version number is also included in the response because it might be different from the one in the request.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.