HTTP (harp.http)¶
- class AlreadyHandledHttpResponse[source]¶
Bases:
HttpResponse
- class BaseHttpMessage[source]¶
Bases:
BaseMessage
- property headers: MultiDictProxy¶
- class HttpError[source]¶
Bases:
BaseHttpMessage
- property headers: MultiDictProxy¶
- class HttpRequest[source]¶
Bases:
BaseHttpMessage
- __init__(impl=None, *, extensions=None, **kwargs)[source]¶
- Parameters:
impl (HttpRequestBridge | None)
extensions (dict | None)
- async aread()[source]¶
Read all chunks from request. We may want to be able to read partial body later, but for now it’s all or nothing. This method does nothing if the body has already been read.
- Return type:
- property body: bytes¶
Returns the previously read body of the request. Raises a RuntimeError if the body has not been read yet, you must await the read() asynchronous method first, which cannot be done here because properties are synchronous, so we let the user explicitely call it before.
- property headers: CIMultiDict¶
- property stream¶
- class HttpRequestBridge[source]¶
Bases:
Protocol
The HttpRequestBridge protocol defines the methods required by the HttpRequest object for it to attach to a real implementation, such as WSGI, ASGI, …
- __init__(*args, **kwargs)¶
- class HttpRequestSerializer[source]¶
Bases:
BaseHttpMessageSerializer
Serialize an HTTP request object into string representations for different message parts:
summary: the first line of the request message (e.g. “GET / HTTP/1.1”)
headers: the headers of the request message (e.g. “Host: localhost:4080
Connection: keep-alive …”)
body: the body of the request message (e.g. b’{“foo”: “bar”}’)
The main goal of this serializer is to prepare a request message for storage.
- wrapped: HttpRequest¶
- class HttpResponse[source]¶
Bases:
BaseHttpMessage
- property headers: CIMultiDict¶
- property stream¶
- class HttpResponseBridge[source]¶
Bases:
Protocol
The HttpResponseBridge protocol defines the necessary methods to actually send an HttpResponse through a real channel.
- __init__(*args, **kwargs)¶
- class JsonHttpResponse[source]¶
Bases:
HttpResponse
- get_serializer_for(message)[source]¶
- Parameters:
message (BaseMessage)
- Return type: