➜

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: urllib does not splitport while putrequest realhost to HTTP headers
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: gr zhang, r.david.murray, xiang.zhang
Priority: normal Keywords:

Created on 2016-06-12 04:10 by gr zhang, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
urllib_part.py gr zhang, 2016-06-12 04:10
Messages (5)
msg268317 - (view) Author: gr zhang (gr zhang) Date: 2016-06-12 04:10
h.putheader('Host', "www.github.com:443")             
# this will make errcode 405, if urllib lib splitport first, and this will set Host ---> www.github.com and get 200 code.
h.endheaders(None)
errcode, errmsg, headers = h.getreply()
print errcode
msg268318 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2016-06-12 04:27
The standard[1] says the Host header is OK to include port. Why not use 'https://www.github.com'?

[1] https://tools.ietf.org/html/rfc7230#section-5.4
msg268326 - (view) Author: gr zhang (gr zhang) Date: 2016-06-12 05:07
Yes, I mean when set h.putheader('Host', "www.github.com:443") and the status code from httplib will be 405 while when set h.putheader('Host', "www.github.com") the code will be 200, this is confused to me.
msg268357 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2016-06-12 10:07
It's server side behaviour. Asking here may not get results. I think it's normal for the server to return error if it thinks the header is invalid.
msg268827 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2016-06-18 19:30
httplib (which is what you are actually calling in your example) does not interpret headers set with putheader.  It is the application's responsibility to get the header contents correct.  As Xiang said, this looks like a server side issue.
History
Date User Action Args
2022-04-11 14:58:32adminsetgithub: 71486
2016-06-18 19:30:11r.david.murraysetstatus: open -> closed

nosy: + r.david.murray
messages: + msg268827

resolution: not a bug
stage: resolved
2016-06-12 10:07:08xiang.zhangsetmessages: + msg268357
2016-06-12 05:07:58gr zhangsetmessages: + msg268326
2016-06-12 04:27:37xiang.zhangsetnosy: + xiang.zhang
messages: + msg268318
2016-06-12 04:10:49gr zhangcreate