Service contexts for accepting HTTP requests.
functools
typing
weakref
match
core
flows
io
ri
http
_prepare_http_transports_v0
_prepare_http_transports_v0(ifctx, ports)
_prepare_http_transports_v1
_prepare_http_transports_v1(ifctx, ports)
_prepare_http_transports_v2
_prepare_http_transports_v2(ifctx, ports)
protocols
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
Request execution controller for HTTP services.
Controllertransportio.Transport
Controllerfrom_accept
from_accept(Class, invp, pair)
Controller__init__
__init__(self, invocations, request, connect_output, connect_input, channel_id)
ControllerconnectNone
connect(self, channel)
Initiate the response causing headers to be sent and connect the channel as the HTTP response entity body. If channel is None, no entity body will be supplied.
Controlleraccept
accept(self, channel)
Connect entity body of the request to the given channel. If channel is None, any entity body sent will trigger a fault.
Controllerhttp_add_headerNone
http_add_header(self, key, value)
Append a single header to the header sequence that will be supplied by the response.
Controlleradd_header
add_header = http_add_header
Controllerhttp_extend_headersNone
http_extend_headers(self, pairs)
Add a sequence of headers.
Controllerextend_headers
extend_headers = http_extend_headers
Controllerhttp_set_response
http_set_response(self, code, descr, length)
Assign the status of the response and designate the transfer encoding. Excepting length, all parameters must be bytes instances; this is intended to emphasize that the fields are being directly inserted into the wire.
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_response
set_response = http_set_response
Controllerhttp_continue
http_continue(self, headers)
Emit a 100 continue response with the given headers. Emitting a continuation after a non-100 response has been sent will fault the Transaction.
Controllerhttp_continueEngineering
Currently, the HTTP implementation presumes one response per transaction which is in conflict with HTTP/1.1's CONTINUE.
Controllerhttp_redirect
http_redirect(self, location)
Location header redirect using a 301-MOVED PERMANENTLY response.
Controller_http_content_headers
_http_content_headers(self, cotype, length)
Define the type and length of the entity body to be sent.
Controllerhttp_dispatch_output
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
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_write_output
http_write_output(self, 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_write_text
http_write_text(self, string)
Send the given data to the remote end with the given mime type. If other headers are desired, they must be configured before running this method.
Controllerhttp_read_file_into_output
http_read_file_into_output(self, route, cotype)
Send the file referenced by route to the remote end as the (HTTP) entity body.
Controllerhttp_read_file_into_outputParameters
Controllerhttp_send_file_head
http_send_file_head(self, route, cotype)
Send the file referenced by route to the remote end as the (HTTP) entity body.
Controllerhttp_send_file_headParameters
Controllerhttp_read_input_into_buffer
http_read_input_into_buffer(self, callback, *args)
Connect the input Flow to a buffer that executes the given callback when the entity body has been transferred.
Controllerhttp_ignore_input
http_ignore_input(self)
Connect the given input to a transfer that discards events.
Network
System Context for managing a set of Host instances. Provides grouping for hosts that share the same system network interface.
NetworkProperties
- http_default_host
The default HTTP Host; the Host to select in cases where no
Hostis designated by a request.
Networkhttp_default_host
http_default_host = None
Network__init__
__init__(self)
Networknet_dispatch
net_dispatch(self, host)
Networknet_select_host
net_select_host(self, name)
Networknet_accept
net_accept(self, invp)
Route the protocol transactions to the designated host. This only enqueues the invocation for subsequent execution.
Networkactuate
actuate(self)
Networkterminate
terminate(self)
Networkxact_void
xact_void(self, final)
Partition
Base class for host applications.
PartitionProperties
Partition__init__
__init__(self, path)
Partitionstructure
structure(self)
Partitionactuate
actuate(self)
Partitionpart_accept
part_accept(self, invp)
Allocate a sequence of controllers and process them using part_select.
Partitionpart_select
part_select(self, ctl)
Partitionterminate
terminate(self)
Partitionxact_void
xact_void(self, final)
Files
Read-only filesystem union for serving local files.
Filespart_dispatched
part_dispatched(self, argv)
Filespart_select
part_select(self, ctl)
Host
An HTTP Host interface for managing routing of service connections, and handling the representation of error cases.
HostProperties
- h_names
The set hostnames that this host can facilitate. The object can be an arbitrary container in order to match patterns as well.
- h_canonical
The first name given to h_update_names. None if no names were given and the name should be inherited from requests.
- h_root
The root of the host's path as a fault.context.match.SubsequenceScan. This is the initial path of the router in order to allow "mounts" at arbitrary positions. Built from requisite prefixes.
- h_allowed_methods
Method restrictions for the host. None if not restricted.
HostEngineering
While proper caching should be handled by a proxy, caching of "constants" should be performed here as well. A constant would be a resource that is designated as being the only possible version when given the same path. Constants would be shared across forks using a mmap region initialized by a parent process.
Hoststrcache
strcache(obj)
Cache for encoded identifiers often used with a host.
Hostdescriptioncache
descriptioncache(obj)
Hosth_defaults
h_defaults = {
'h_options': (),
'h_allowed_methods': frozenset({
b'GET', b'HEAD', b'POST', b'PUT',
b'PATCH', b'DELETE', b'OPTIONS'
}),
}
Hosth_canonical
h_canonical = None
Hosth_names
h_names = None
Hosth_options
h_options = None
Hosth_allowed_methods
h_allowed_methods = h_defaults['h_allowed_methods']
Hosth_redirects
h_redirects = None
Hosth_headers
h_headers = ()
Hostactuate
actuate(self)
Hosth_enable_options
h_enable_options(self, *option_identifiers)
Hosth_disable_options
h_disable_options(self, *option_identifiers)
Hosth_set_headers
h_set_headers(self, headers)
Hosth_update_names
h_update_names(self, *names)
Modify the host names that this interface responds to.
Host__init__
__init__(self, partitions)
Hosth_set_redirects
h_set_redirects(self, target, origins)
Hosth_clear_redirects
h_clear_redirects(self)
Hosth_configure
h_configure(self, partitions)
Configure and dispatch the host's partitions.
Hosth_connect
h_connect(self, partition)
Add the given partition to the host.
Hosth_disconnect
h_disconnect(self, partition)
Terminate and remove the partition identified by its path.
Hoststructure
structure(self)
Hosth_options_request
h_options_request(self, ctl)
Handle a request for OPTIONS * HTTP/x.x. Individual Resources may support an OPTIONS request as well.
Hosth_error
h_error(self, ctl, code, exc)
Host error handler. By default, emits an XML document with an assigned stylesheet that can be retrieved for formatting the error. Additional error data may by injected into the document in order to provide application-level error information.
Given the details about an HTTP error message and the corresponding fault.web.http.IO, emit the rendered error to the client.
Hosth_fallback
h_fallback(self, ctl)
Method called when no prefix matches the request.
Provided for subclasses in order to override the usual 404.
Hosth_route
h_route(self, ctl)
Route the request to the identified partition.
Host_h_redirected
_h_redirected(target, ctl)
Host_h_direct
_h_direct(self, ctl)
Hosth_accept
h_accept(self, invp)
Allocate a sequence of controllers and process them using h_route.
Hostterminate
terminate(self)
Hostxact_void
xact_void(self, final)