fault.web

Client projection dispatch management.

Provides Contexts for managing a client's sessions.

Engineering

Agents are fairly complicated with respect to preferences. The current implementation presumes HTTP/1.1 in most cases where a protocol priority should be used to select a desired wire protocol.

Navigation and Session are essentially unimplemented. Finding a generic structure that fits all use cases is unlikely; however, the direction of a traditional user agent model should be sufficient in most cases.

typing
import

weakref
import

core
import

flows
import

io
import

http
import

_prepare_http_transports_v0
function

_prepare_http_transports_v0(ifctx, ports)

_prepare_http_transports_v1
function

_prepare_http_transports_v1(ifctx, ports)

_prepare_http_transports_v2
function

_prepare_http_transports_v2(ifctx, ports)

protocols
data

protocols = {
	'http': _prepare_http_transports_v0, # Adjustable.
	'http-1': _prepare_http_transports_v1, # Strictly 1.0/1.1 only.
	'http-2': _prepare_http_transports_v2, # Not implemented
}

Controller
class

Request execution controller for HTTP agents.

ControllerProperties

http_response

The http.Structures instance representing the response status and headers.

Controllerhttp_response
data

http_response = None
	@property

Controllertransport
property
io.Transport

Controller__init__
method

__init__(self, invocations, channel_id, connect_output)

Controller_correlation
method

_correlation(self, channel_id, parameters, connect_input)

Controllerhttp_add_header
method

http_add_header(self, key, value)

Append a single header to the header sequence that will be supplied by the response.

Controlleradd_header
data

add_header = http_add_header

Controllerhttp_extend_headers
method

http_extend_headers(self, pairs)

Add a sequence of headers.

Controllerextend_headers
data

extend_headers = http_extend_headers

Controllerhttp_set_request
method

http_set_request(self, method, uri, length)

Assign the method and URI of the request and designate the transfer encoding. Excepting length, all parameters must be bytes instances.

If cotype is None, neither Content-Length nor Transfer-Encoding will be appended to the headers.

If cotype is not None and length is None, chunked transfer encoding will be used. If cotype is not None and length is an integer, Content-Length will be provided.

Controllerset_request
data

set_request = http_set_request

Controllerconnect
method

connect(self, channel)

Initiate the request causing headers to be sent and connect the channel as the HTTP request's entity body. If channel is None, no entity body will be supplied.

Controlleraccept
method

accept(self, channel)

Accept the entity-body of the response into channel. If channel is None, any entity body sent will trigger a fault.

Controller_http_content_headers
method

_http_content_headers(self, cotype, length)

Define the type and length of the entity body to be sent.

Controllerhttp_dispatch_output
method

http_dispatch_output(self, channel)

Dispatch the given channel using a new fault.kernel.io.Transfer instance into invocations' fault.kernel.io.Transport transaction.

Controllerhttp_iterate_output
method

http_iterate_output(self, iterator)

Construct a Flow consisting of a single fault.kernel.flows.Iterate instance used to stream output to the connection protocol state.

The fault.kernel.io.Transfer transaction will be dispatched into the fault.kernel.io.Transport supporting the connection to the remote peer.

Controllerhttp_put_data
method

http_put_data(self, uri, cotype, data)

Send the given data to the remote end with the given content type, cotype. If other headers are desired, they must be configured before running this method.

Controllerhttp_read_input_into_buffer
method

http_read_input_into_buffer(self, callback, *args)

Connect the input to a buffer that executes the given callback when the entity body has been transferred.

Controllerhttp_read_input_into_file
method

http_read_input_into_file(self, path)

Connect the input to a buffer that executes the given callback when the entity body has been transferred.

Controllerhttp_ignore_input
method

http_ignore_input(self)

Connect the given input to a transfer that discards events.

Session
class

Session dispatching invocation projections for facilitating a request.

Session__init__
method

__init__(self)

Sessions_correlate
method

s_correlate(self, inv)

Sessionxact_exit
method

xact_exit(self, xact)

Sessionactuate
method

actuate(self)

RInvocation
class

An HTTP request received by a service and its determined response headers and status.

The parameters should store exact bytes instances that were read by the transport. Higher-level interfaces, http.Structures, should often decode these field accordingly.

RInvocationProperties

headers

The sequence of headers held by the parameters of the request.

method

The request method held by the parameters.

path

The request URI held by the parameters.

RInvocationprojection
data

projection = True

RInvocationcontext
data

context = None
	@property

RInvocationheaders
property
http.HeaderSequence

RInvocationmethod
property
str

Decoded form of the request's method.

RInvocationpath
property
str

Decoded form of the request URI's path.

RInvocationdeclare_output_length
method

declare_output_length(self, length)

RInvocationdeclare_output_chunked
method

declare_output_chunked(self)

RInvocation__init__
method

__init__(self, exit_method, method, path, headers)

RInvocation__str__
method

__str__(self)

RInvocationfrom_request
classmethod

from_request(Class, rline, headers)

Initialize an Invocation using a parsed request line and headers. Primarily, this is used by fork in a server context.