You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
urllib does not splitport while putrequest realhost to HTTP headers #71486
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:
assignee=Noneclosed_at=<Date2016-06-18.19:30:11.260>created_at=<Date2016-06-12.04:10:49.837>labels= ['invalid', 'type-bug', 'library']
title='urllib does not splitport while putrequest realhost to HTTP headers'updated_at=<Date2016-06-18.19:30:11.258>user='https://bugs.python.org/grzhang'
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()
printerrcode
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.
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.
Activity
grzhang commentedon Jun 12, 2016
zhangyangyu commentedon Jun 12, 2016
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
grzhang commentedon Jun 12, 2016
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.
zhangyangyu commentedon Jun 12, 2016
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.
bitdancer commentedon Jun 18, 2016
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.