http.server has support for old-style HTTP 0.9 requests ("command path" without a version string). This issue proposes to remove this support, since there are probably no clients around which still issue such requests.
The question really is whether we want or want not to support RFC 1945 (i.e HTTP/1.0). If we want to support it, we also must comply to section 3.1, which says
The version of an HTTP message is indicated by an HTTP-Version field
in the first line of the message. If the protocol version is not
specified, the recipient must assume that the message is in the
simple HTTP/0.9 format.
If we then choose to not support HTTP/0.9 (after recognizing that the message is HTTP/0.9), we must then reject the request. According to RFC 2145, we then may send back error 505 (HTTP version not supported).
If a client sends a request without specifying the version, GET /, then the Python server should behave like other common servers are behaving, namely support rfc 1945 for HTTP 1.0 spec and return the response without headers.
Removing the HTTP 0.9 from the http.client is okay. But punishing *any client* for not sending the correct request is not so desirable, especially when there are other servers which are lenient to his behavior for whatever reasons.
So, I am not a firm +1 to this. We should arrive a conclusion and then go about with the change. Martin's point is valid here too.
BreamoreBoy commented on Jun 26, 2014
BreamoreBoymannequin
Mannequin
More actions
How, if at all, has the requirement for HTTP 0.9 support changed since this issue was first raised?
Lukasa commented on Jun 26, 2014
Lukasamannequin
Mannequin
More actions
To answer your question, Mark, RFC 7230 has removed the expectation that HTTP/1.1 servers will be able to support HTTP/0.9 requests.
Does this need any deprecation cycle, or can we just remove everything immediately in 3.6?
I suspect that the HTTP 0.9 support never properly worked, but I don’t have enough info to be sure. Wouldn’t a HTTP 0.9 request send b"GET <path>\r\n" with a single line, and then wait for a response? If so, Python’s server hangs waiting for a second blank line (or EOF), so the protocol will deadlock.
In any case, I would be in favour of removing HTTP 0.9 support. Senthil: do you know of actual clients that do HTTP 0.9 requests?
I left a review comment. The patch will also need manual merging with current code.
This v2 patch adds another test that includes what I understand is a true HTTP 0.9 request (although the mock connection infrastructure closes the connection before receiving the response, so you don’t see any deadlock). This is based on <https://tools.ietf.org/html/rfc1945#page-22\>, which includes only one CRLF newline. I also added an entry to the What’s New page.
There is so very little code in support of HTTP/0.9 that I don't think we get any benefit from removing it. So why bother with the churn? It is cleaner to just leave it place.
There are a few small benefits from removing it, but I am not too fussed if we decide to leave it.
If we keep it, should we fix it so that it doesn’t deadlock? Otherwise, we carry around buggy and untested code that claims to be a HTTP 0.9 server but isn’t. Keeping it as it is doesn’t feel “clean” to me.
Here is a slightly updated patch I have been sitting on. I think the main difference was tweaks to the documentation.
bpo-28548 would also benefit if the HTTP 0.9 code was removed. The presence of the HTTP 0.9 code means a suboptimal response is sent in some error cases. IMO it would be better if the server responded using HTTP 1.0, where we can use error codes like “400 Bad request”. The current code will not use HTTP 1.0 unless it sees that the client supports it.
Raymond: Given the problems caused by the current code, would you reconsider your opposition?
Otherwise, what do you think should be the future of the code? Should we fix it so that it handles real HTTP 0.9 requests, or just admit that it doesn’t implement the protocol properly.
The deadlock on HTTP/0.9 requests was fixed in gh-70765.
The remaining defect is that error responses to malformed request lines are sent in the bare HTTP/0.9 style, without a status line and headers. #152980 fixes this.
After that this issue can be closed, since HTTP/0.9 support now works and removing it was objected to.
Activity
pitrou commented on Dec 16, 2010
http.server has support for old-style HTTP 0.9 requests ("command path" without a version string). This issue proposes to remove this support, since there are probably no clients around which still issue such requests.
See bpo-10711 for the client side.
merwok commented on Dec 16, 2010
LGTM
loewis commented on Dec 17, 2010
The question really is whether we want or want not to support RFC 1945 (i.e HTTP/1.0). If we want to support it, we also must comply to section 3.1, which says
The version of an HTTP message is indicated by an HTTP-Version field
in the first line of the message. If the protocol version is not
specified, the recipient must assume that the message is in the
simple HTTP/0.9 format.
If we then choose to not support HTTP/0.9 (after recognizing that the message is HTTP/0.9), we must then reject the request. According to RFC 2145, we then may send back error 505 (HTTP version not supported).
orsenthil commented on Dec 17, 2010
If a client sends a request without specifying the version, GET /, then the Python server should behave like other common servers are behaving, namely support rfc 1945 for HTTP 1.0 spec and return the response without headers.
Removing the HTTP 0.9 from the http.client is okay. But punishing *any client* for not sending the correct request is not so desirable, especially when there are other servers which are lenient to his behavior for whatever reasons.
So, I am not a firm +1 to this. We should arrive a conclusion and then go about with the change. Martin's point is valid here too.
BreamoreBoy commented on Jun 26, 2014
How, if at all, has the requirement for HTTP 0.9 support changed since this issue was first raised?
Lukasa commented on Jun 26, 2014
To answer your question, Mark, RFC 7230 has removed the expectation that HTTP/1.1 servers will be able to support HTTP/0.9 requests.
vadmium commented on Mar 18, 2016
Does this need any deprecation cycle, or can we just remove everything immediately in 3.6?
I suspect that the HTTP 0.9 support never properly worked, but I don’t have enough info to be sure. Wouldn’t a HTTP 0.9 request send b"GET <path>\r\n" with a single line, and then wait for a response? If so, Python’s server hangs waiting for a second blank line (or EOF), so the protocol will deadlock.
In any case, I would be in favour of removing HTTP 0.9 support. Senthil: do you know of actual clients that do HTTP 0.9 requests?
I left a review comment. The patch will also need manual merging with current code.
vadmium commented on Mar 18, 2016
Also I guess documentation should be added somewhere, even if there is no deprecation step.
vadmium commented on Aug 10, 2016
FWIW I doubt HTTP 1.1 ever required support for other HTTP versions; see for instance <https://tools.ietf.org/html/rfc2068#section-19.7\>.
This v2 patch adds another test that includes what I understand is a true HTTP 0.9 request (although the mock connection infrastructure closes the connection before receiving the response, so you don’t see any deadlock). This is based on <https://tools.ietf.org/html/rfc1945#page-22\>, which includes only one CRLF newline. I also added an entry to the What’s New page.
rhettinger commented on Aug 11, 2016
There is so very little code in support of HTTP/0.9 that I don't think we get any benefit from removing it. So why bother with the churn? It is cleaner to just leave it place.
vadmium commented on Aug 11, 2016
There are a few small benefits from removing it, but I am not too fussed if we decide to leave it.
If we keep it, should we fix it so that it doesn’t deadlock? Otherwise, we carry around buggy and untested code that claims to be a HTTP 0.9 server but isn’t. Keeping it as it is doesn’t feel “clean” to me.
Easy way to resolve bug reports like bpo-26578.
Potentially slightly easier to maintain the rest of the code in the future.
If we do keep it, I would like to add comments clarifying that it does not implement the real HTTP 0.9 protocol.
vadmium commented on Oct 29, 2016
Here is a slightly updated patch I have been sitting on. I think the main difference was tweaks to the documentation.
bpo-28548 would also benefit if the HTTP 0.9 code was removed. The presence of the HTTP 0.9 code means a suboptimal response is sent in some error cases. IMO it would be better if the server responded using HTTP 1.0, where we can use error codes like “400 Bad request”. The current code will not use HTTP 1.0 unless it sees that the client supports it.
vadmium commented on Nov 24, 2016
V4 patch adjusting to recent code change.
Raymond: Given the problems caused by the current code, would you reconsider your opposition?
Otherwise, what do you think should be the future of the code? Should we fix it so that it handles real HTTP 0.9 requests, or just admit that it doesn’t implement the protocol properly.
serhiy-storchaka commented on Jul 3, 2026
The deadlock on HTTP/0.9 requests was fixed in gh-70765.
The remaining defect is that error responses to malformed request lines are sent in the bare HTTP/0.9 style, without a status line and headers. #152980 fixes this.
After that this issue can be closed, since HTTP/0.9 support now works and removing it was objected to.
gh-54930: Send a status line in error responses to malformed request …
[3.13] gh-54930: Send a status line in error responses to malformed r…
[3.14] gh-54930: Send a status line in error responses to malformed r…
[3.15] gh-54930: Send a status line in error responses to malformed r…