Commit 866cb0e
committed
gh-141938: Fix HTTPConnection being stuck in a dirty state when response.begin() raises exceptions
When response.begin() raises an exception other than ConnectionError
(such as TimeoutError), the outer exception handler calls
response.close() but not self.close(), leaving the HTTPConnection's
internal state stuck at _CS_REQ_SENT instead of being reset to _CS_IDLE.
This causes subsequent requests on the same connection to raise
CannotSendRequest even though the underlying socket has been closed.
The fix changes the outer exception handler to call self.close() instead
of just response.close(). This properly resets the connection state and
closes the socket, consistent with the inner ConnectionError handler.1 parent 5ec03cf commit 866cb0e
2 files changed
Lines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1449 | 1449 | | |
1450 | 1450 | | |
1451 | 1451 | | |
1452 | | - | |
| 1452 | + | |
1453 | 1453 | | |
1454 | 1454 | | |
1455 | 1455 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
0 commit comments