Skip to content

Document socket property of Response objects #199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading