http.transport

HTTP transport helpers for the webapp request handler.

These utilities centralize UTF-8 response writing and JSON body parsing so the request handler can focus on route dispatch and endpoint behavior.

Functions

send_text(handler, content, *[, status, content_type])

Write a UTF-8 text response through a BaseHTTPRequestHandler-like object.

send_bytes(handler, payload, *[, status, content_type])

Write raw binary data through a BaseHTTPRequestHandler-like object.

send_json(handler, payload, *[, status])

Serialize and write a JSON object response.

read_json_body(handler)

Read and validate a JSON object request body from the handler stream.

Module Contents

http.transport.send_text(handler, content, *, status=200, content_type='text/plain')

Write a UTF-8 text response through a BaseHTTPRequestHandler-like object.

http.transport.send_bytes(handler, payload, *, status=200, content_type='application/octet-stream')

Write raw binary data through a BaseHTTPRequestHandler-like object.

http.transport.send_json(handler, payload, *, status=200)

Serialize and write a JSON object response.

http.transport.read_json_body(handler)

Read and validate a JSON object request body from the handler stream.