Skip to content

Add WSGI and ASGI dispatchers #49

Closed

Description

@lovelydinosaur

We should allow clients to trivially plug into WSGI and ASGI apps.
This will allow:

  • Using httpcore as a test client.
  • Stubbing out third-party-services during tests, rather than making live network requests.

We should support the following:

def hello_world(environ, start_response):
    ...

client = Client(app=hello_world)

And...

async def hello_world(scope, receive, send):
    ...

client = Client(app=hello_world)

This is easy enough for us to do, since we've already got a dispatch=... interface, so we'll want something like this:

if app is not None:
    if is_coroutine(app):
        dispatch = ASGIDispatcher(app)
    else:
        dispatch = WSGIDispatcher(app)

We'll then need ASGIDispatcher and WSGIDispatcher implementations, which implement Dispatcher.send().

Activity

  1. lovelydinosaur commented on May 24, 2019

    @lovelydinosaur
    MemberAuthor

    Related #79 - required for the WSGI case.

  2. lovelydinosaur commented on Jun 24, 2019

    @lovelydinosaur
    MemberAuthor

    Done.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions