[Python-ideas] why is not request in httplib pretty printed?
Matěj Cepl
mcepl at redhat.com
Fri Dec 6 23:09:46 CET 2013
Hi,
looking at
http://hg.python.org/cpython/file/543c76769c14/Lib/http/client.py#l847
(but this code has been same since like forever) I see that the
HTTP request is NOT pretty printed:
if self.debuglevel > 0:
print("send:", repr(data))
whereas response in effect (because every header is printed
separately) is. Wouldn't it be better to pretty print the
request as well?
Otherwise I get quite unreadable debugging logs like the
following (notice how much response is more readable than
request).
Matěj
matej at wycliff: urllib2_kerberos (next *%)$ python test_trac.py
send: 'GET /desktopqe-backlog/login HTTP/1.1\r\nAccept-Encoding: identity\r\nHost: someserver.redhat.com\r\nConnection: close\r\nUser-Agent: Python-urllib/2.7\r\n\r\n'
reply: 'HTTP/1.1 401 Authorization Required\r\n'
header: Date: Fri, 06 Dec 2013 17:11:13 GMT
header: Server: Apache
header: WWW-Authenticate: Negotiate
header: WWW-Authenticate: Basic realm="Kerberos Login"
header: Content-Length: 483
header: Connection: close
header: Content-Type: text/html; charset=iso-8859-1
2013-12-06 18:11:15,406 DEBUG inside http_error_401
2013-12-06 18:11:15,407 DEBUG retry count: 1
2013-12-06 18:11:15,407 DEBUG req.get_host() returned someserver.redhat.com
2013-12-06 18:11:15,407 DEBUG authGSSClientInit() succeeded
2013-12-06 18:11:15,486 DEBUG authGSSClientStep() succeeded
2013-12-06 18:11:15,486 DEBUG authGSSClientResponse() succeeded
send: 'GET /desktopqe-backlog/login HTTP/1.1\r\nAccept-Encoding: identity\r\nHost: someserver.redhat.com\r\nConnection: close\r\nAuthorization: Negotiate YIICdQYJKoZIhvcSA---some-junk--GZDggzt\r\nUser-Agent: Python-urllib/2.7\r\n\r\n'
reply: 'HTTP/1.1 302 Found\r\n'
header: Date: Fri, 06 Dec 2013 17:11:14 GMT
header: Server: Apache
header: WWW-Authenticate: Negotiate YIGZBgkqhkiG9xIB--other-junk--NOxMdOR/5
header: Location: https://someserver.redhat.com/desktopqe-backlog
header: Content-Length: 0
header: Pragma: no-cache
header: Cache-Control: no-cache
header: Expires: Fri, 01 Jan 1999 00:00:00 GMT
header: Set-Cookie: trac_auth=148d029eb321e9a0782fd30ca3f9d17b; Path=/desktopqe-backlog; secure
header: Connection: close
header: Content-Type: text/plain; charset=UTF-8
send: 'GET /desktopqe-backlog HTTP/1.1\r\nAccept-Encoding: identity\r\nHost: someserver.redhat.com\r\nConnection: close\r\nUser-Agent: Python-urllib/2.7\r\n\r\n'
reply: 'HTTP/1.1 200 OK\r\n'
header: Date: Fri, 06 Dec 2013 17:11:15 GMT
header: Server: Apache
header: Cache-Control: must-revalidate
header: Expires: Fri, 01 Jan 1999 00:00:00 GMT
header: Content-Length: 9591
header: Set-Cookie: trac_form_token=a6eda80ba3f4ead82093a0af; Path=/desktopqe-backlog; secure
header: Set-Cookie: trac_session=213441ab7934999739979a04; expires=Thu, 06-Mar-2014 17:11:15 GMT; Path=/desktopqe-backlog; secure
header: Connection: close
header: Content-Type: text/html;charset=utf-8
2013-12-06 18:11:17,190 DEBUG www-authenticate header not found
2013-12-06 18:11:17,190 CRITICAL mutual auth failed. No negotiate header
matej at wycliff: urllib2_kerberos (next *%)$
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20131206/5ec40775/attachment.sig>
More information about the Python-ideas
mailing list