-
Notifications
You must be signed in to change notification settings - Fork 35
Need supported way to "steal" socket from requests library for mp3 streaming #198
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
Comments
Isn't the In
And |
It is a HTTPResponse object in standard Python, but it supports the >>> response = requests.get("http://example.com", headers={'connection': 'close', 'accept-encoding': ''}, stream=True)
>>> response.raw
<urllib3.response.HTTPResponse object at 0x7f23ee80be50>
>>> response.raw.read(32)
b'<!doctype html>\n<html>\n<head>\n '
>>> response.raw.recv
AttributeError: 'HTTPResponse' object has no attribute 'recv' In CicuitPython a socket object supports and I don't want to add a type to Requests that wraps a socket to provide read in terms of recv. For my purposes, an intermediate object, especially one coded in Python code, is undesirable, because dropping back into arbitrary Python code from a background task causes problems and we avoid it whenever possible. |
if we just decide to document the |
I understand not wanting to pass the wrapper to have read. Although for CircuitPython, returning the socket as raw would break anything written in python... |
Also, any desire to do this the standard way:
I know |
This FAQ, https://requests.readthedocs.io/en/latest/community/faq/#encoded-data, says
Is |
|
file numbers really aren't a thing in circuitpython, though |
Right now I do this:
but
requests
The real requests library has a public
raw
property that calling code may use when the request includesstream=True
. So simply renaming thesocket
property toraw
would be one step in the right direction. (the stream argument is already supported in adafruit_requests)As for properly releasing the socket, I guess I need to restructure my code so it can hold onto the requests object as long as needed.
The text was updated successfully, but these errors were encountered: