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: Socket closed prematurely in httplib for https
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: ABR, iritkatriel, thomaslee
Priority: normal Keywords:

Created on 2012-09-27 16:08 by ABR, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (4)
msg171379 - (view) Author: ABR (ABR) Date: 2012-09-27 16:08
When attempting to use basic auth over https with a server that sends 401 and closes the connection as soon as the headers missing auth are received, the process aborts with a broken pipe when (presumably) trying to send the POST body.

session = requests.session(auth=(USER, PASSWORD), verify=False)
resp = session.post('https://foo.com/something')
  --> requests.exceptions.ConnectionError: [Errno 32] Broken pipe
msg171408 - (view) Author: Thomas Lee (thomaslee) (Python committer) Date: 2012-09-28 06:47
Thanks ABR. You may be better off raising a ticket against requests (https://github.com/kennethreitz/requests).

I'm assuming what you want to happen here is for the session.post() call to return the 401 response without raising an exception. Perfectly reasonable, but to the best of my knowledge the "requests" library isn't in Python's standard library -- and so this is not the place to get it fixed :)
msg171440 - (view) Author: ABR (ABR) Date: 2012-09-28 11:34
If that's where the bug is.  I forgot to mention this issue seems identical to 5542 (http://bugs.python.org/issue5542), but for https.  The fix there was in the underlying url/httplib.
msg392258 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-04-28 21:03
Issue5542 was fixed, so if it's the same thing this is also fixed. If it's not the same thing, then python 2.7 is past EOL so please create a new issue if you can reproduce this problem in 3.8+.
History
Date User Action Args
2022-04-11 14:57:36adminsetgithub: 60266
2021-04-28 21:03:55iritkatrielsetstatus: open -> closed

nosy: + iritkatriel
messages: + msg392258

resolution: out of date
stage: resolved
2012-09-28 11:34:16ABRsetmessages: + msg171440
2012-09-28 06:47:35thomasleesetnosy: + thomaslee
messages: + msg171408
2012-09-27 16:08:14ABRcreate