Skip to content

Server-side requests/responses #1091

@lovelydinosaur

Description

@lovelydinosaur

So, not something that we need to support as a primary use-case, but something we ought to just think about a little before 1.0, is making sure that our Request and Response models can be used on the server side as well.

For instance...

  • It'd be beneficial if libraries like starlette were able to lean heavily on httpx.
  • It'd make for easier custom transport implementations, if users were able to eg. instantiate a request instance, given the incoming raw request info. (Since that's a bit easier to worth with that the raw byte-wise API.)

A couple of API/implementation notes to go along with this...

  • URL() should accept the raw bytes URL 4-tuple format that the httpcore API uses as one of it's options.
  • Request.prepare(...) shouldn't be called automatically on __init__. The Client should call it explicitly in build_request(). This ensures that we'd be able to instantiate a Request instance from the raw HTTP core method/url/headers/stream` information, without having additional headers automatically generated on the model.
  • We might want Request.raw, Response.raw, Headers.raw properties, to match up with the existing URL.raw property.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions