[issue15799] httplib client and statusline

Senthil Kumaran report at bugs.python.org
Fri Sep 26 09:04:11 CEST 2014


Senthil Kumaran added the comment:

Sorry that I did not get involved earlier.

It is difficult to prove any problem with the current behavior and it is rightly closed. The issue which was originally raised seems to me a cosmetic one, which won't get exhibited as well.

Here is  simple test case and the output with the current behavior.

# testcases.py

testcases = ["HTTP/1.1 200", "HTTP/1.1 200 OK", "HTTP/1.1 200  ", "HTTP/1.1   200"]
for tc in testcases:
    try:
        version, status, reason = tc.split(None, 2)
        print "%s (%s,%s,%s)" % (tc, version, status, reason)
    except ValueError:
        version, status = tc.split(None, 1)
        print "%s (%s, %s)" % (tc, version, status)


$ python testcases.py
HTTP/1.1 200 (HTTP/1.1, 200)
HTTP/1.1 200 OK (HTTP/1.1,200,OK)
HTTP/1.1 200   (HTTP/1.1, 200  )
HTTP/1.1   200 (HTTP/1.1, 200)

The problem is the status code (str at the moment) has a trailing spaces. 
And now, the status code is not used as string. Just after the parsing, the status is converted to integer, Line 337: status = int(status) and rest of urllib and http/client's behavior use status as int rather than as string.

Thanks!

----------
type: enhancement -> behavior

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15799>
_______________________________________


More information about the Python-bugs-list mailing list