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

Introduce session.make_request() API #2019

Open
asvetlov opened this issue Jun 26, 2017 · 3 comments
Open

Introduce session.make_request() API #2019

asvetlov opened this issue Jun 26, 2017 · 3 comments
Assignees
Milestone

Comments

@asvetlov
Copy link
Member

Now we support request payload streaming in a bit reverse way: we could pass a generator as data parameter to client.request() but it makes things harder because of Reverse of Control. Handling back pressure and errors in generator are complicated.
Also sometimes people should pass semi-supported custom request_class for calculating custom headers etc.
Last Trailer headers support #1652 also requires some kind of callback -- which is not elegant at least.

I suggest adding new client.make_request(url, params, headers, ...) method.
The method returns ClientStreamRequest object.

The request is not started at moment of creation but has headers prepared.
User could modify them without subclassing.

The request has .connect() coroutine for connection negotiation (it works with proxies implicitly).
After connection established user calls .send_headers() coro, later .write() coro several times maybe, .send_trailers() if needed and .write_eof().
ClientStreamRequest API should be pretty much close to web.StreamResponse.

All existing client API should be built around ClientStreamRequest calls.

I pretty sure this is viable approach that might make non-trivial usages much simpler than now.

@fafhrd91
Copy link
Member

I like it

@kxepal
Copy link
Member

kxepal commented Jun 27, 2017

+1

@alexmnazarenko
Copy link

+1, it would be nice for my use-case (essentially, app sometimes behaves like a proxy server, so it is forced to use streaming APIs)

@asvetlov asvetlov self-assigned this Nov 1, 2017
@asvetlov asvetlov changed the title [idea] Introduce session.make_request() API Introduce session.make_request() API Nov 1, 2017
@asvetlov asvetlov added this to the 3.0 milestone Nov 1, 2017
@asvetlov asvetlov modified the milestones: 3.0, 3.1 Feb 9, 2018
@asvetlov asvetlov modified the milestones: 3.1, 3.2 Mar 22, 2018
@asvetlov asvetlov modified the milestones: 3.2, 3.3 May 7, 2018
@asvetlov asvetlov modified the milestones: 3.3, 3.5 Oct 18, 2018
@asvetlov asvetlov modified the milestones: 3.5, 4.0 Oct 12, 2019
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

5 participants