Ayak973 Ayak973 - 1 year ago 124
HTTP Question

HTTP version mismatch - server response code

I'm trying to code an HTTP 1.0 (and only 1.0 for the moment) server in C++.

I've read the HTTP 1.0 specs here : https://www.w3.org/Protocols/HTTP/1.0/spec.html.
On section 3 "Protocol Parameters", subsection 3.1 "HTTP Version", i've found nothing when a client sent a different version from the server.

According to https://www.w3.org/DesignIssues/Protocolcomms.html, when version mismatch, we have two possibilities:

  • Version(server) = Version(client) + 1 : Should downgrade to the previous version (Impossible? My server handle only one specific version - may i have to handle HTTP 0.9?)

  • Version(server) > Version(client) + 1: An alert is given to the user (wich one? 4xx, 5xx?)

An official quote from the IETF RFC's should be appreciable, or at least an example with current most used web servers like Apache or Nginx.

Answer Source

You seem to be interpreting the last-mentioned document incorrectly. In your case, the issue is v(ME) < v(IT) (or v(ME) + 1 = v(IT)), and the document doesn't present a solution for that situation.

However, RFC 2616 (HTTP/1.1) states (in 19.6):

And we would expect HTTP/1.1 clients to:

  • recognize the format of the Status-Line for HTTP/1.0 and 1.1 responses;

  • understand any valid response in the format of HTTP/0.9, 1.0, or 1.1.

So if you implement a fully compliant 1.0 server, the client should accept its responses.

RFC 7230 also has some pointers on how to deal with 1.1 clients.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download