harp.http.serializers

Inheritance diagram of harp.http.serializers

class BaseHttpMessageSerializer[source]

Bases: MessageSerializer

Base serializer for HTTP messages.

__init__(message)[source]
Parameters:

message (BaseHttpMessage)

property body: bytes
property headers: str
property summary: str
class HttpErrorSerializer[source]

Bases: BaseHttpMessageSerializer

Serialize an HTTP error object into string representations for different message parts:

  • summary: the error message

  • headers: empty

  • body: stack trace (xxx this may change, maybe too much info and too much internal)

The main goal of this serializer is to prepare an error message for storage.

property summary: str
wrapped: HttpError
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.

property query_string: str
property summary: str
wrapped: HttpRequest
class HttpResponseSerializer[source]

Bases: BaseHttpMessageSerializer

Serialize an HTTP response object into string representations for different message parts:

  • summary: the first line of the response message (e.g. “HTTP/1.1 200 OK”)

  • headers: the headers of the response message (e.g. “Content-Type: text/plain

Content-Length: 13 …”)

  • body: the body of the response message (e.g. b’Hello, world!’)

The main goal of this serializer is to prepare a response message for storage.

property summary: str
wrapped: HttpResponse
get_serializer_for(message)[source]
Parameters:

message (BaseMessage)

Return type:

MessageSerializer