aiocoap.proxy.server module¶
Basic implementation of CoAP-CoAP proxying
This is work in progress and not yet part of the API.
- exception aiocoap.proxy.server.CanNotRedirect(message=None)¶
Bases:
ConstructionRenderableError
- message = 'Proxy redirection failed'¶
Text sent in the built message’s payload
- exception aiocoap.proxy.server.NoUriSplitting(message=None)¶
Bases:
CanNotRedirect
- code = <Response Code 161 "5.01 Not Implemented">¶
Code assigned to messages built from it
- message = 'URI splitting not implemented, please use Proxy-Scheme.'¶
Text sent in the built message’s payload
- exception aiocoap.proxy.server.IncompleteProxyUri(message=None)¶
Bases:
CanNotRedirect
- code = <Response Code 128 "4.00 Bad Request">¶
Code assigned to messages built from it
- message = 'Proxying requires Proxy-Scheme and Uri-Host'¶
Text sent in the built message’s payload
- exception aiocoap.proxy.server.NotAForwardProxy(message=None)¶
Bases:
CanNotRedirect
- code = <Response Code 165 "5.05 Proxying Not Supported">¶
Code assigned to messages built from it
- message = 'This is a reverse proxy, not a forward one.'¶
Text sent in the built message’s payload
- exception aiocoap.proxy.server.NoSuchHostname(message=None)¶
Bases:
CanNotRedirect
- code = <Response Code 132 "4.04 Not Found">¶
Code assigned to messages built from it
- message = ''¶
Text sent in the built message’s payload
- exception aiocoap.proxy.server.CanNotRedirectBecauseOfUnsafeOptions(options)¶
Bases:
CanNotRedirect
- code = <Response Code 130 "4.02 Bad Option">¶
Code assigned to messages built from it
- aiocoap.proxy.server.raise_unless_safe(request, known_options)¶
Raise a BAD_OPTION CanNotRedirect unless all options in request are safe to forward or known
- class aiocoap.proxy.server.Proxy(outgoing_context, logger=None)¶
Bases:
Resource
- interpret_block_options = False¶
- add_redirector(redirector)¶
- apply_redirection(request)¶
- async needs_blockwise_assembly(request)¶
Indicator to the
protocol.Responder
about whether it should assemble request blocks to a single request and extract the requested blocks from a complete-resource answer (True), or whether the resource will do that by itself (False).
- async render(request)¶
Return a message that can be sent back to the requester.
This does not need to set any low-level message options like remote, token or message type; it does however need to set a response code.
A response returned may carry a no_response option (which is actually specified to apply to requests only); the underlying transports will decide based on that and its code whether to actually transmit the response.
- async render_to_pipe(request: Pipe)¶
Create any number of responses (as indicated by the request) into the request stream.
This method is provided by the base Resource classes; if it is overridden, then
render()
,needs_blockwise_assembly()
andadd_observation()
are not used any more. (They still need to be implemented to comply with the interface definition, which is yet to be updated).
- class aiocoap.proxy.server.ProxyWithPooledObservations(outgoing_context, logger=None)¶
Bases:
Proxy
,ObservableResource
- async add_observation(request, serverobservation)¶
As ProxiedResource is intended to be just the proxy’s interface toward the Context, accepting observations is handled here, where the observations handling can be defined by the subclasses.
- async render(request)¶
Return a message that can be sent back to the requester.
This does not need to set any low-level message options like remote, token or message type; it does however need to set a response code.
A response returned may carry a no_response option (which is actually specified to apply to requests only); the underlying transports will decide based on that and its code whether to actually transmit the response.
- class aiocoap.proxy.server.ForwardProxy(outgoing_context, logger=None)¶
Bases:
Proxy
- apply_redirection(request)¶
- class aiocoap.proxy.server.ForwardProxyWithPooledObservations(outgoing_context, logger=None)¶
- class aiocoap.proxy.server.ReverseProxyWithPooledObservations(*args, **kwargs)¶
- class aiocoap.proxy.server.NameBasedVirtualHost(match_name, target, rewrite_uri_host=False, use_as_proxy=False)¶
Bases:
Redirector
- apply_redirection(request)¶
- class aiocoap.proxy.server.SubdomainVirtualHost(*args, **kwargs)¶
Bases:
NameBasedVirtualHost
- class aiocoap.proxy.server.UnconditionalRedirector(target, use_as_proxy=False)¶
Bases:
Redirector
- apply_redirection(request)¶
- class aiocoap.proxy.server.SubresourceVirtualHost(path, target)¶
Bases:
Redirector
- apply_redirection(request)¶