New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HTTPResponse.msg not as documented #67178
Comments
HTTPResponse.msg is documented as a http.client.HTTPMessage object containing the headers of the response [1]. But in fact this is a string containing the status code: >>> import urllib.request
>>> req=urllib.request.urlopen('http://heise.de')
>>> content = req.read()
>>> type(req.msg)
<class 'str'>
>>> req.msg
'OK' This value is apparently overriden in urllib/request.py: ./urllib/request.py:1246: # This line replaces the .msg attribute of the HTTPResponse Anyhow, it should be documented, that is not safe to retrieve the headers with HTTPResponse.msg and maybe add HTTPResponse.headers to the documentation. |
See bpo-21228 for a patch which documents the “.msg” hack, and that the info() method is available for HTTP responses. I think documenting the “.headers” attribute would be a bad idea, because it is introducing yet another way to do what the almost-documented info() method already does. |
Documenting the “headers” attribute is also discussed in bpo-12707 |
New changeset fa3c9faabfb0 by Martin Panter in branch '3.4': New changeset b55c006b79bc by Martin Panter in branch '3.5': New changeset c6930661599b by Martin Panter in branch 'default': |
The documentation now mentions the “msg” quirk and the info() method. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: