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

a middle-level layer for the server #952

Closed
faassen opened this issue Jul 4, 2016 · 3 comments
Closed

a middle-level layer for the server #952

faassen opened this issue Jul 4, 2016 · 3 comments
Labels

Comments

@faassen
Copy link

faassen commented Jul 4, 2016

When you want to implement a HTTP server using aiohttp you currently have two choices:

  • buy into the full stack. This lets you use the request and response object, and includes the application object and the router.
  • buy into the ServerHttpProtocol. This is very low-level.

I'm interested in the equivalent of webob: have a request a response object, but no assumptions about routing or the way applications get constructed. So something built on top of ServerHttpProtocol that lets you use the request and response objects but no other assumptions made. This would:

  • make my current task easier: I'm trying to write a HTTP proxy using aiohttp's client and server facilities. A proxy doesn't need the router, but it is helped by the request object.
  • would make it easier for web frameworks to be built on top of aiohttp that are an alternative to the one it ships with.

I've been trying to engage with the low-level ServerHttpProtocol layer to see how far I can get. I ran into the following difficulties:

  • the new test_util.TestClient expects an app object. I hacked around this by making a subclass that takes a handler instead, but it would be nicer if this class existed in the framework.
  • in order to figure out the http scheme I want the equivalent to request.scheme. I ended up initializing a Request object manually and passing None as the first argument, as this is supposed to be an app instance. I noticed that the server Request depends on app but very minimally so, but it still expects the app as the first argument. I'm looking for a request object that doesn't depend on the app at all.
  • I'm now trying to figure out how to run a low-level handler with gunicorn, but the documentation only discusses the app level so I'm currently lost.

My impression from the documentation and the code is that this "middle layer" is not really a priority of the framework. People are pointed to the higher level application object. The test client doesn't support the use case either. aiohttp tantalizingly close to supporting this use case, but it isn't quite there.

So my question the developers is this one: is this something you're interested in supporting with aiohttp at all, or is this just not interesting to you? Would you accept contributions that moved aiohttp into this direction?

@asvetlov
Copy link
Member

Yes, personally I have no need for mid-level but I'm open for proposals.
If you will produce a Pull Request with careful splitting high level API from mid level request/response objects I'll take a look.

@asvetlov asvetlov mentioned this issue Nov 4, 2016
@asvetlov
Copy link
Member

Fixed by #1362

@lock
Copy link

lock bot commented Oct 29, 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.

@lock lock bot added the outdated label Oct 29, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 29, 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

2 participants