Skip to content
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

Stream requests #280

Open
leiserfg opened this issue Oct 24, 2022 · 2 comments
Open

Stream requests #280

leiserfg opened this issue Oct 24, 2022 · 2 comments

Comments

@leiserfg
Copy link
Contributor

Is there a way to pass stream=True to specific requests?
I happen to have to talk to an API that returns a file in one of its endpoints and it will be nice to stream it down.

@leiserfg
Copy link
Contributor Author

For reference, I ended up doing:

class AsStream(TransactionHook):
    def audit_request(self, consumer, request_builder):
        request_builder.info["stream"] = True
        return super().audit_request(consumer, request_builder)
as_stream = AsStream()

class Client(up.Consumer):
    @up.inject(as_stream)
    @up.get('/file')
    def get_file():
        ...  

@leiserfg
Copy link
Contributor Author

leiserfg commented Jun 14, 2023

@prkumar I think it is a requests only feature but it should be added to the documentation at least.

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

No branches or pull requests

2 participants