Skip to content

Commit

Permalink
Merge pull request #199 from adafruit/document-socket-property
Browse files Browse the repository at this point in the history
Document socket property of Response objects
  • Loading branch information
dhalbert authored Jul 4, 2024
2 parents 4b55319 + 376fff2 commit 347a527
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 347a527

Please sign in to comment.