Skip to content

requests: stream parameter is noop #777

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

Open
tmplt opened this issue Dec 9, 2023 · 0 comments
Open

requests: stream parameter is noop #777

tmplt opened this issue Dec 9, 2023 · 0 comments

Comments

@tmplt
Copy link

tmplt commented Dec 9, 2023

MicroPython v1.21.0; Raspberry Pi Pico W with RP2040.

requests.request exposes a stream=None parameter:

def request(
method,
url,
data=None,
json=None,
headers={},
stream=None,
auth=None,
timeout=None,
parse_headers=True,
):

but it is never functionally used, nor is some iter_content API exposed; the parameter is only forwarded to recursive request calls.

Workaround:

r = requests.get(...)
# sidestep @property content, which just reads socket data into memory until EOF
s = r.raw
r.raw = None
buf = bytearray(1024)
while s.readinto(buf) > 0:
    # handle data in buf (e.g. write to file)

if the above is implemented into some iter_content, is the stream parameter even needed? Am I missing something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant