Skip to content

Commit 11aef21

Browse files
authored
gh-141938: document treatment of OSError raised by HTTPConnection.getresponse (#142339)
1 parent e90e6d1 commit 11aef21

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

Doc/library/http.client.rst

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,12 @@ HTTPConnection Objects
319319
:class:`str` or bytes-like object that is not also a file as the
320320
body representation.
321321

322+
.. note::
323+
324+
Note that you must have read the whole response or call :meth:`close`
325+
if :meth:`getresponse` raised an non-:exc:`ConnectionError` exception
326+
before you can send a new request to the server.
327+
322328
.. versionchanged:: 3.2
323329
*body* can now be an iterable.
324330

@@ -334,16 +340,15 @@ HTTPConnection Objects
334340
Should be called after a request is sent to get the response from the server.
335341
Returns an :class:`HTTPResponse` instance.
336342

337-
.. note::
338-
339-
Note that you must have read the whole response before you can send a new
340-
request to the server.
341-
342343
.. versionchanged:: 3.5
343344
If a :exc:`ConnectionError` or subclass is raised, the
344345
:class:`HTTPConnection` object will be ready to reconnect when
345346
a new request is sent.
346347

348+
Note that this does not apply to :exc:`OSError`\s raised by the underlying
349+
socket. Instead the caller is responsible to call :meth:`close` on the
350+
existing connection.
351+
347352

348353
.. method:: HTTPConnection.set_debuglevel(level)
349354

0 commit comments

Comments
 (0)