This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: BaseHTTPServer incorrectly parses protocol
Type: Stage:
Components: None Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: akuchling Nosy List: akuchling, dalke, nnorwitz
Priority: normal Keywords:

Created on 2003-01-28 19:38 by dalke, last changed 2022-04-10 16:06 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
BaseHTTPServer.diff dalke, 2003-01-30 00:12
Messages (4)
msg14270 - (view) Author: Andrew Dalke (dalke) * (Python committer) Date: 2003-01-28 19:38
The code in
BaseHTTPServer.BaseHTTPRequestHandler.parse_request says

            try:
                version_number =
float(version.split('/', 1)[1])
            except ValueError:
                self.send_error(400, "Bad request
version (%s)" % `version`)
                return False
            if version_number >= 1.1 and
self.protocol_version >= "HTTP/1.1":
                self.close_connection = 0
            if version_number >= 2.0:
                self.send_error(505,
                                "Invalid HTTP Version
(%f)" % version_number)

This does not agree with the HTTP/1.1 spec which states

Note that the major and minor numbers MUST be treated
as separate
integers and that each MAY be incremented higher than a
single
digit. Thus, HTTP/2.4 is a lower version than
HTTP/2.13, which in turn
is lower than HTTP/12.3. Leading zeros MUST be ignored
by recipients
and MUST NOT be sent.

I also noticed there were errors if the version string
was "HTTP/1.2.3" or even simply "BLAH".  I've fixed
them so they don't give tracebacks.

Finally, if there is an error in the parsing, it calls
the 'send_error'
method, which does a check if 'self.command' is a HEAD.
 However,
if there's an error parsing the first line of the HTTP
request the
self.command wasn't yet set, so I forced self.command
to initialized to None before doing anything which can
yield an error.

Patch is attached.

msg14271 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2003-01-29 21:22
Logged In: YES 
user_id=33168

There's no uploaded file!  You have to check the
checkbox labeled "Check to Upload & Attach File"
when you upload a file.

Please try again.

(This is a SourceForge annoyance that we can do
nothing about. :-( )
msg14272 - (view) Author: Andrew Dalke (dalke) * (Python committer) Date: 2003-01-30 00:12
Logged In: YES 
user_id=190903

Silly interface.  Okay, should be attached now.
msg14273 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2003-02-03 19:17
Logged In: YES 
user_id=11375

Checked in as revision 1.24 of BaseHTTPServer.py; thanks!  
(You should probably double-check the CVS version, just to be sure I didn't mess something up.)
History
Date User Action Args
2022-04-10 16:06:15adminsetgithub: 37856
2003-01-28 19:38:01dalkecreate