Skip to content

Commit

Permalink
Document socket property of Response objects
Browse files Browse the repository at this point in the history
  • Loading branch information
jepler committed Jul 1, 2024
1 parent 4b55319 commit 376fff2
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions adafruit_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,21 @@ class Response:
# pylint: disable=too-many-instance-attributes

encoding = None
socket: SocketType
"""The underlying socket object (CircuitPython extension, not in standard requests)
Under the following circumstances, calling code may directly access the underlying
socket object:
* The request was made with ``stream=True``
* The request headers included ``{'connection': 'close'}``
* No methods or properties on the Response object that access the response content
may be used
Methods and properties that access response headers may be accessed.
It is still necessary to ``close`` the response object for correct management of
sockets, including doing so implicitly via ``with requests.get(...) as response``."""

def __init__(self, sock: SocketType, session: "Session") -> None:
self.socket = sock
Expand Down

0 comments on commit 376fff2

Please sign in to comment.