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

Implement streaming request data generation for ClientRequest #1721

Closed
socketpair opened this issue Mar 16, 2017 · 7 comments
Closed

Implement streaming request data generation for ClientRequest #1721

socketpair opened this issue Mar 16, 2017 · 7 comments
Labels
Milestone

Comments

@socketpair
Copy link
Contributor

socketpair commented Mar 16, 2017

i.e. possible API (pseudocode, actual API may be completely different):

with web.ClientSession() as session:
    async with session.post('/') as req:
        writestream = req.get_write_stream()
        writestream.write('xxx')
        await writestream.drain()
        writestream.write_eof()
        ...

In my case, I have unknown amount of data that sould be sent in the body of the POST-request (i.e. chunked request). Streaming request/response is available for server-side. But for client-side, streaming requests are not available...Maybe I miss something ?

@fafhrd91
Copy link
Member

@fafhrd91
Copy link
Member

I like your idea, I need to think how implementation could look like

@fafhrd91 fafhrd91 added this to the 2.1 milestone Mar 16, 2017
@socketpair
Copy link
Contributor Author

wow. http://aiohttp.readthedocs.io/en/stable/client_reference.html#aiohttp.ClientSession.request said that:

image

So, it does not mention that this can be stream, actually...
Also,
image

Is writer.write() really coroutine ?

@fafhrd91
Copy link
Member

it is new subsystem in 2.0, there is payload registry, it is not documented yet.

here is payload implementation for StreamReader https://github.com/aio-libs/aiohttp/blob/master/aiohttp/payload.py#L263

technically writer.write() is not a coroutine, but I would use it as coroutine because it does drain()
writer is an instance if PayloadWriter class https://github.com/aio-libs/aiohttp/blob/master/aiohttp/http_writer.py#L130

@fafhrd91
Copy link
Member

with payloads you can do fancy stuff like this:

https://github.com/aio-libs/aiohttp/blob/master/tests/test_web_functional.py#L1526

@fafhrd91 fafhrd91 modified the milestones: 2.2, 2.1 May 2, 2017
@asvetlov
Copy link
Member

Superseded by #2802

@lock
Copy link

lock bot commented Oct 28, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a [new issue] for related bugs.
If you feel like there's important points made in this discussion, please include those exceprts into that [new issue].
[new issue]: https://github.com/aio-libs/aiohttp/issues/new

@lock lock bot added the outdated label Oct 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants