Module spin_sdk.wit.imports.types
This interface defines all of the types and methods for implementing HTTP Requests and Responses, both incoming and outgoing, as well as their headers, trailers, and bodies.
Global variables
var ErrorCode-
These cases are inspired by the IANA HTTP Proxy Error Types: https://www.iana.org/assignments/http-proxy-status/http-proxy-status.xhtml#table-http-proxy-error-types
var HeaderError-
This type enumerates the different kinds of errors that may occur when setting or appending to a
fieldsresource. var Method-
This type corresponds to HTTP standard Methods.
var Scheme-
This type corresponds to HTTP standard Related Schemes.
Functions
def http_error_code(err: Error) ‑> ErrorCode_DnsTimeout | ErrorCode_DnsError | ErrorCode_DestinationNotFound | ErrorCode_DestinationUnavailable | ErrorCode_DestinationIpProhibited | ErrorCode_DestinationIpUnroutable | ErrorCode_ConnectionRefused | ErrorCode_ConnectionTerminated | ErrorCode_ConnectionTimeout | ErrorCode_ConnectionReadTimeout | ErrorCode_ConnectionWriteTimeout | ErrorCode_ConnectionLimitReached | ErrorCode_TlsProtocolError | ErrorCode_TlsCertificateError | ErrorCode_TlsAlertReceived | ErrorCode_HttpRequestDenied | ErrorCode_HttpRequestLengthRequired | ErrorCode_HttpRequestBodySize | ErrorCode_HttpRequestMethodInvalid | ErrorCode_HttpRequestUriInvalid | ErrorCode_HttpRequestUriTooLong | ErrorCode_HttpRequestHeaderSectionSize | ErrorCode_HttpRequestHeaderSize | ErrorCode_HttpRequestTrailerSectionSize | ErrorCode_HttpRequestTrailerSize | ErrorCode_HttpResponseIncomplete | ErrorCode_HttpResponseHeaderSectionSize | ErrorCode_HttpResponseHeaderSize | ErrorCode_HttpResponseBodySize | ErrorCode_HttpResponseTrailerSectionSize | ErrorCode_HttpResponseTrailerSize | ErrorCode_HttpResponseTransferCoding | ErrorCode_HttpResponseContentCoding | ErrorCode_HttpResponseTimeout | ErrorCode_HttpUpgradeFailed | ErrorCode_HttpProtocolError | ErrorCode_LoopDetected | ErrorCode_ConfigurationError | ErrorCode_InternalError | None-
Expand source code
def http_error_code(err: error.Error) -> Optional[ErrorCode]: """ Attempts to extract a http-related `error` from the wasi:io `error` provided. Stream operations which return `wasi:io/stream/stream-error::last-operation-failed` have a payload of type `wasi:io/error/error` with more information about the operation that failed. This payload can be passed through to this function to see if there's http-related information about the error to return. Note that this function is fallible because not all io-errors are http-related errors. """ raise NotImplementedErrorAttempts to extract a http-related
errorfrom the wasi:ioerrorprovided.Stream operations which return
wasi:io/stream/stream-error::last-operation-failedhave a payload of typewasi:io/error/errorwith more information about the operation that failed. This payload can be passed through to this function to see if there's http-related information about the error to return.Note that this function is fallible because not all io-errors are http-related errors.
Classes
class DnsErrorPayload (rcode: str | None, info_code: int | None)-
Expand source code
@dataclass class DnsErrorPayload: """ Defines the case payload type for `DNS-error` above: """ rcode: Optional[str] info_code: Optional[int]Defines the case payload type for
DNS-errorabove:Instance variables
var info_code : int | Nonevar rcode : str | None
class ErrorCode_ConfigurationError-
Expand source code
@dataclass class ErrorCode_ConfigurationError: passErrorCode_ConfigurationError()
class ErrorCode_ConnectionLimitReached-
Expand source code
@dataclass class ErrorCode_ConnectionLimitReached: passErrorCode_ConnectionLimitReached()
class ErrorCode_ConnectionReadTimeout-
Expand source code
@dataclass class ErrorCode_ConnectionReadTimeout: passErrorCode_ConnectionReadTimeout()
class ErrorCode_ConnectionRefused-
Expand source code
@dataclass class ErrorCode_ConnectionRefused: passErrorCode_ConnectionRefused()
class ErrorCode_ConnectionTerminated-
Expand source code
@dataclass class ErrorCode_ConnectionTerminated: passErrorCode_ConnectionTerminated()
class ErrorCode_ConnectionTimeout-
Expand source code
@dataclass class ErrorCode_ConnectionTimeout: passErrorCode_ConnectionTimeout()
class ErrorCode_ConnectionWriteTimeout-
Expand source code
@dataclass class ErrorCode_ConnectionWriteTimeout: passErrorCode_ConnectionWriteTimeout()
class ErrorCode_DestinationIpProhibited-
Expand source code
@dataclass class ErrorCode_DestinationIpProhibited: passErrorCode_DestinationIpProhibited()
class ErrorCode_DestinationIpUnroutable-
Expand source code
@dataclass class ErrorCode_DestinationIpUnroutable: passErrorCode_DestinationIpUnroutable()
class ErrorCode_DestinationNotFound-
Expand source code
@dataclass class ErrorCode_DestinationNotFound: passErrorCode_DestinationNotFound()
-
Expand source code
@dataclass class ErrorCode_DestinationUnavailable: passErrorCode_DestinationUnavailable()
class ErrorCode_DnsError (value: DnsErrorPayload)-
Expand source code
@dataclass class ErrorCode_DnsError: value: DnsErrorPayloadErrorCode_DnsError(value: spin_sdk.wit.imports.types.DnsErrorPayload)
Instance variables
var value : DnsErrorPayload
class ErrorCode_DnsTimeout-
Expand source code
@dataclass class ErrorCode_DnsTimeout: passErrorCode_DnsTimeout()
class ErrorCode_HttpProtocolError-
Expand source code
@dataclass class ErrorCode_HttpProtocolError: passErrorCode_HttpProtocolError()
class ErrorCode_HttpRequestBodySize (value: int | None)-
Expand source code
@dataclass class ErrorCode_HttpRequestBodySize: value: Optional[int]ErrorCode_HttpRequestBodySize(value: Optional[int])
Instance variables
var value : int | None
class ErrorCode_HttpRequestDenied-
Expand source code
@dataclass class ErrorCode_HttpRequestDenied: passErrorCode_HttpRequestDenied()
class ErrorCode_HttpRequestHeaderSectionSize (value: int | None)-
Expand source code
@dataclass class ErrorCode_HttpRequestHeaderSectionSize: value: Optional[int]ErrorCode_HttpRequestHeaderSectionSize(value: Optional[int])
Instance variables
var value : int | None
class ErrorCode_HttpRequestHeaderSize (value: FieldSizePayload | None)-
Expand source code
@dataclass class ErrorCode_HttpRequestHeaderSize: value: Optional[FieldSizePayload]ErrorCode_HttpRequestHeaderSize(value: Optional[spin_sdk.wit.imports.types.FieldSizePayload])
Instance variables
var value : FieldSizePayload | None
class ErrorCode_HttpRequestLengthRequired-
Expand source code
@dataclass class ErrorCode_HttpRequestLengthRequired: passErrorCode_HttpRequestLengthRequired()
class ErrorCode_HttpRequestMethodInvalid-
Expand source code
@dataclass class ErrorCode_HttpRequestMethodInvalid: passErrorCode_HttpRequestMethodInvalid()
class ErrorCode_HttpRequestTrailerSectionSize (value: int | None)-
Expand source code
@dataclass class ErrorCode_HttpRequestTrailerSectionSize: value: Optional[int]ErrorCode_HttpRequestTrailerSectionSize(value: Optional[int])
Instance variables
var value : int | None
class ErrorCode_HttpRequestTrailerSize (value: FieldSizePayload)-
Expand source code
@dataclass class ErrorCode_HttpRequestTrailerSize: value: FieldSizePayloadErrorCode_HttpRequestTrailerSize(value: spin_sdk.wit.imports.types.FieldSizePayload)
Instance variables
var value : FieldSizePayload
class ErrorCode_HttpRequestUriInvalid-
Expand source code
@dataclass class ErrorCode_HttpRequestUriInvalid: passErrorCode_HttpRequestUriInvalid()
class ErrorCode_HttpRequestUriTooLong-
Expand source code
@dataclass class ErrorCode_HttpRequestUriTooLong: passErrorCode_HttpRequestUriTooLong()
class ErrorCode_HttpResponseBodySize (value: int | None)-
Expand source code
@dataclass class ErrorCode_HttpResponseBodySize: value: Optional[int]ErrorCode_HttpResponseBodySize(value: Optional[int])
Instance variables
var value : int | None
class ErrorCode_HttpResponseContentCoding (value: str | None)-
Expand source code
@dataclass class ErrorCode_HttpResponseContentCoding: value: Optional[str]ErrorCode_HttpResponseContentCoding(value: Optional[str])
Instance variables
var value : str | None
class ErrorCode_HttpResponseHeaderSectionSize (value: int | None)-
Expand source code
@dataclass class ErrorCode_HttpResponseHeaderSectionSize: value: Optional[int]ErrorCode_HttpResponseHeaderSectionSize(value: Optional[int])
Instance variables
var value : int | None
class ErrorCode_HttpResponseHeaderSize (value: FieldSizePayload)-
Expand source code
@dataclass class ErrorCode_HttpResponseHeaderSize: value: FieldSizePayloadErrorCode_HttpResponseHeaderSize(value: spin_sdk.wit.imports.types.FieldSizePayload)
Instance variables
var value : FieldSizePayload
class ErrorCode_HttpResponseIncomplete-
Expand source code
@dataclass class ErrorCode_HttpResponseIncomplete: passErrorCode_HttpResponseIncomplete()
class ErrorCode_HttpResponseTimeout-
Expand source code
@dataclass class ErrorCode_HttpResponseTimeout: passErrorCode_HttpResponseTimeout()
class ErrorCode_HttpResponseTrailerSectionSize (value: int | None)-
Expand source code
@dataclass class ErrorCode_HttpResponseTrailerSectionSize: value: Optional[int]ErrorCode_HttpResponseTrailerSectionSize(value: Optional[int])
Instance variables
var value : int | None
class ErrorCode_HttpResponseTrailerSize (value: FieldSizePayload)-
Expand source code
@dataclass class ErrorCode_HttpResponseTrailerSize: value: FieldSizePayloadErrorCode_HttpResponseTrailerSize(value: spin_sdk.wit.imports.types.FieldSizePayload)
Instance variables
var value : FieldSizePayload
class ErrorCode_HttpResponseTransferCoding (value: str | None)-
Expand source code
@dataclass class ErrorCode_HttpResponseTransferCoding: value: Optional[str]ErrorCode_HttpResponseTransferCoding(value: Optional[str])
Instance variables
var value : str | None
class ErrorCode_HttpUpgradeFailed-
Expand source code
@dataclass class ErrorCode_HttpUpgradeFailed: passErrorCode_HttpUpgradeFailed()
class ErrorCode_InternalError (value: str | None)-
Expand source code
@dataclass class ErrorCode_InternalError: value: Optional[str]ErrorCode_InternalError(value: Optional[str])
Instance variables
var value : str | None
class ErrorCode_LoopDetected-
Expand source code
@dataclass class ErrorCode_LoopDetected: passErrorCode_LoopDetected()
class ErrorCode_TlsAlertReceived (value: TlsAlertReceivedPayload)-
Expand source code
@dataclass class ErrorCode_TlsAlertReceived: value: TlsAlertReceivedPayloadErrorCode_TlsAlertReceived(value: spin_sdk.wit.imports.types.TlsAlertReceivedPayload)
Instance variables
var value : TlsAlertReceivedPayload
class ErrorCode_TlsCertificateError-
Expand source code
@dataclass class ErrorCode_TlsCertificateError: passErrorCode_TlsCertificateError()
class ErrorCode_TlsProtocolError-
Expand source code
@dataclass class ErrorCode_TlsProtocolError: passErrorCode_TlsProtocolError()
class FieldSizePayload (field_name: str | None, field_size: int | None)-
Expand source code
@dataclass class FieldSizePayload: """ Defines the case payload type for `HTTP-response-{header,trailer}-size` above: """ field_name: Optional[str] field_size: Optional[int]Defines the case payload type for
HTTP-response-{header,trailer}-sizeabove:Instance variables
var field_name : str | Nonevar field_size : int | None
class Fields-
Expand source code
class Fields: """ This following block defines the `fields` resource which corresponds to HTTP standard Fields. Fields are a common representation used for both Headers and Trailers. A `fields` may be mutable or immutable. A `fields` created using the constructor, `from-list`, or `clone` will be mutable, but a `fields` resource given by other means (including, but not limited to, `incoming-request.headers`, `outgoing-request.headers`) might be be immutable. In an immutable fields, the `set`, `append`, and `delete` operations will fail with `header-error.immutable`. """ def __init__(self) -> None: """ Construct an empty HTTP Fields. The resulting `fields` is mutable. """ raise NotImplementedError @classmethod def from_list(cls, entries: List[Tuple[str, bytes]]) -> Self: """ Construct an HTTP Fields. The resulting `fields` is mutable. The list represents each key-value pair in the Fields. Keys which have multiple values are represented by multiple entries in this list with the same key. The tuple is a pair of the field key, represented as a string, and Value, represented as a list of bytes. In a valid Fields, all keys and values are valid UTF-8 strings. However, values are not always well-formed, so they are represented as a raw list of bytes. An error result will be returned if any header or value was syntactically invalid, or if a header was forbidden. Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.types.HeaderError)` """ raise NotImplementedError def get(self, name: str) -> List[bytes]: """ Get all of the values corresponding to a key. If the key is not present in this `fields`, an empty list is returned. However, if the key is present but empty, this is represented by a list with one or more empty field-values present. """ raise NotImplementedError def has(self, name: str) -> bool: """ Returns `true` when the key is present in this `fields`. If the key is syntactically invalid, `false` is returned. """ raise NotImplementedError def set(self, name: str, value: List[bytes]) -> None: """ Set all of the values for a key. Clears any existing values for that key, if they have been set. Fails with `header-error.immutable` if the `fields` are immutable. Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.types.HeaderError)` """ raise NotImplementedError def delete(self, name: str) -> None: """ Delete all values for a key. Does nothing if no values for the key exist. Fails with `header-error.immutable` if the `fields` are immutable. Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.types.HeaderError)` """ raise NotImplementedError def append(self, name: str, value: bytes) -> None: """ Append a value for a key. Does not change or delete any existing values for that key. Fails with `header-error.immutable` if the `fields` are immutable. Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.types.HeaderError)` """ raise NotImplementedError def entries(self) -> List[Tuple[str, bytes]]: """ Retrieve the full set of keys and values in the Fields. Like the constructor, the list represents each key-value pair. The outer list represents each key-value pair in the Fields. Keys which have multiple values are represented by multiple entries in this list with the same key. """ raise NotImplementedError def clone(self) -> Self: """ Make a deep copy of the Fields. Equivelant in behavior to calling the `fields` constructor on the return value of `entries`. The resulting `fields` is mutable. """ raise NotImplementedError def __enter__(self) -> Self: """Returns self""" return self def __exit__(self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None) -> bool | None: """ Release this resource. """ raise NotImplementedErrorThis following block defines the
fieldsresource which corresponds to HTTP standard Fields. Fields are a common representation used for both Headers and Trailers.A
fieldsmay be mutable or immutable. Afieldscreated using the constructor,from-list, orclonewill be mutable, but afieldsresource given by other means (including, but not limited to,incoming-request.headers,outgoing-request.headers) might be be immutable. In an immutable fields, theset,append, anddeleteoperations will fail withheader-error.immutable.Construct an empty HTTP Fields.
The resulting
fieldsis mutable.Static methods
def from_list(entries: List[Tuple[str, bytes]]) ‑> Self-
Construct an HTTP Fields.
The resulting
fieldsis mutable.The list represents each key-value pair in the Fields. Keys which have multiple values are represented by multiple entries in this list with the same key.
The tuple is a pair of the field key, represented as a string, and Value, represented as a list of bytes. In a valid Fields, all keys and values are valid UTF-8 strings. However, values are not always well-formed, so they are represented as a raw list of bytes.
An error result will be returned if any header or value was syntactically invalid, or if a header was forbidden.
Raises:
Err(HeaderError)
Methods
def append(self, name: str, value: bytes) ‑> None-
Expand source code
def append(self, name: str, value: bytes) -> None: """ Append a value for a key. Does not change or delete any existing values for that key. Fails with `header-error.immutable` if the `fields` are immutable. Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.types.HeaderError)` """ raise NotImplementedErrorAppend a value for a key. Does not change or delete any existing values for that key.
Fails with
header-error.immutableif thefieldsare immutable.Raises:
Err(HeaderError) def clone(self) ‑> Self-
Expand source code
def clone(self) -> Self: """ Make a deep copy of the Fields. Equivelant in behavior to calling the `fields` constructor on the return value of `entries`. The resulting `fields` is mutable. """ raise NotImplementedErrorMake a deep copy of the Fields. Equivelant in behavior to calling the
fieldsconstructor on the return value ofentries. The resultingfieldsis mutable. def delete(self, name: str) ‑> None-
Expand source code
def delete(self, name: str) -> None: """ Delete all values for a key. Does nothing if no values for the key exist. Fails with `header-error.immutable` if the `fields` are immutable. Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.types.HeaderError)` """ raise NotImplementedErrorDelete all values for a key. Does nothing if no values for the key exist.
Fails with
header-error.immutableif thefieldsare immutable.Raises:
Err(HeaderError) def entries(self) ‑> List[Tuple[str, bytes]]-
Expand source code
def entries(self) -> List[Tuple[str, bytes]]: """ Retrieve the full set of keys and values in the Fields. Like the constructor, the list represents each key-value pair. The outer list represents each key-value pair in the Fields. Keys which have multiple values are represented by multiple entries in this list with the same key. """ raise NotImplementedErrorRetrieve the full set of keys and values in the Fields. Like the constructor, the list represents each key-value pair.
The outer list represents each key-value pair in the Fields. Keys which have multiple values are represented by multiple entries in this list with the same key.
def get(self, name: str) ‑> List[bytes]-
Expand source code
def get(self, name: str) -> List[bytes]: """ Get all of the values corresponding to a key. If the key is not present in this `fields`, an empty list is returned. However, if the key is present but empty, this is represented by a list with one or more empty field-values present. """ raise NotImplementedErrorGet all of the values corresponding to a key. If the key is not present in this
fields, an empty list is returned. However, if the key is present but empty, this is represented by a list with one or more empty field-values present. def has(self, name: str) ‑> bool-
Expand source code
def has(self, name: str) -> bool: """ Returns `true` when the key is present in this `fields`. If the key is syntactically invalid, `false` is returned. """ raise NotImplementedErrorReturns
truewhen the key is present in thisfields. If the key is syntactically invalid,falseis returned. def set(self, name: str, value: List[bytes]) ‑> None-
Expand source code
def set(self, name: str, value: List[bytes]) -> None: """ Set all of the values for a key. Clears any existing values for that key, if they have been set. Fails with `header-error.immutable` if the `fields` are immutable. Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.types.HeaderError)` """ raise NotImplementedErrorSet all of the values for a key. Clears any existing values for that key, if they have been set.
Fails with
header-error.immutableif thefieldsare immutable.Raises:
Err(HeaderError)
class FutureIncomingResponse-
Expand source code
class FutureIncomingResponse: """ Represents a future which may eventaully return an incoming HTTP Response, or an error. This resource is returned by the `wasi:http/outgoing-handler` interface to provide the HTTP Response corresponding to the sent Request. """ def subscribe(self) -> poll.Pollable: """ Returns a pollable which becomes ready when either the Response has been received, or an error has occured. When this pollable is ready, the `get` method will return `some`. """ raise NotImplementedError def get(self) -> Optional[Result[Result[IncomingResponse, ErrorCode], None]]: """ Returns the incoming HTTP Response, or an error, once one is ready. The outer `option` represents future readiness. Users can wait on this `option` to become `some` using the `subscribe` method. The outer `result` is used to retrieve the response or error at most once. It will be success on the first call in which the outer option is `some`, and error on subsequent calls. The inner `result` represents that either the incoming HTTP Response status and headers have recieved successfully, or that an error occured. Errors may also occur while consuming the response body, but those will be reported by the `incoming-body` and its `output-stream` child. """ raise NotImplementedError def __enter__(self) -> Self: """Returns self""" return self def __exit__(self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None) -> bool | None: """ Release this resource. """ raise NotImplementedErrorRepresents a future which may eventaully return an incoming HTTP Response, or an error.
This resource is returned by the
wasi:http/outgoing-handlerinterface to provide the HTTP Response corresponding to the sent Request.Methods
def get(self) ‑> Ok[Ok[IncomingResponse] | Err[ErrorCode_DnsTimeout | ErrorCode_DnsError | ErrorCode_DestinationNotFound | ErrorCode_DestinationUnavailable | ErrorCode_DestinationIpProhibited | ErrorCode_DestinationIpUnroutable | ErrorCode_ConnectionRefused | ErrorCode_ConnectionTerminated | ErrorCode_ConnectionTimeout | ErrorCode_ConnectionReadTimeout | ErrorCode_ConnectionWriteTimeout | ErrorCode_ConnectionLimitReached | ErrorCode_TlsProtocolError | ErrorCode_TlsCertificateError | ErrorCode_TlsAlertReceived | ErrorCode_HttpRequestDenied | ErrorCode_HttpRequestLengthRequired | ErrorCode_HttpRequestBodySize | ErrorCode_HttpRequestMethodInvalid | ErrorCode_HttpRequestUriInvalid | ErrorCode_HttpRequestUriTooLong | ErrorCode_HttpRequestHeaderSectionSize | ErrorCode_HttpRequestHeaderSize | ErrorCode_HttpRequestTrailerSectionSize | ErrorCode_HttpRequestTrailerSize | ErrorCode_HttpResponseIncomplete | ErrorCode_HttpResponseHeaderSectionSize | ErrorCode_HttpResponseHeaderSize | ErrorCode_HttpResponseBodySize | ErrorCode_HttpResponseTrailerSectionSize | ErrorCode_HttpResponseTrailerSize | ErrorCode_HttpResponseTransferCoding | ErrorCode_HttpResponseContentCoding | ErrorCode_HttpResponseTimeout | ErrorCode_HttpUpgradeFailed | ErrorCode_HttpProtocolError | ErrorCode_LoopDetected | ErrorCode_ConfigurationError | ErrorCode_InternalError]] | Err[None] | None-
Expand source code
def get(self) -> Optional[Result[Result[IncomingResponse, ErrorCode], None]]: """ Returns the incoming HTTP Response, or an error, once one is ready. The outer `option` represents future readiness. Users can wait on this `option` to become `some` using the `subscribe` method. The outer `result` is used to retrieve the response or error at most once. It will be success on the first call in which the outer option is `some`, and error on subsequent calls. The inner `result` represents that either the incoming HTTP Response status and headers have recieved successfully, or that an error occured. Errors may also occur while consuming the response body, but those will be reported by the `incoming-body` and its `output-stream` child. """ raise NotImplementedErrorReturns the incoming HTTP Response, or an error, once one is ready.
The outer
optionrepresents future readiness. Users can wait on thisoptionto becomesomeusing thesubscribemethod.The outer
resultis used to retrieve the response or error at most once. It will be success on the first call in which the outer option issome, and error on subsequent calls.The inner
resultrepresents that either the incoming HTTP Response status and headers have recieved successfully, or that an error occured. Errors may also occur while consuming the response body, but those will be reported by theincoming-bodyand itsoutput-streamchild. def subscribe(self) ‑> Pollable-
Expand source code
def subscribe(self) -> poll.Pollable: """ Returns a pollable which becomes ready when either the Response has been received, or an error has occured. When this pollable is ready, the `get` method will return `some`. """ raise NotImplementedErrorReturns a pollable which becomes ready when either the Response has been received, or an error has occured. When this pollable is ready, the
getmethod will returnsome.
class FutureTrailers-
Expand source code
class FutureTrailers: """ Represents a future which may eventaully return trailers, or an error. In the case that the incoming HTTP Request or Response did not have any trailers, this future will resolve to the empty set of trailers once the complete Request or Response body has been received. """ def subscribe(self) -> poll.Pollable: """ Returns a pollable which becomes ready when either the trailers have been received, or an error has occured. When this pollable is ready, the `get` method will return `some`. """ raise NotImplementedError def get(self) -> Optional[Result[Result[Optional[Fields], ErrorCode], None]]: """ Returns the contents of the trailers, or an error which occured, once the future is ready. The outer `option` represents future readiness. Users can wait on this `option` to become `some` using the `subscribe` method. The outer `result` is used to retrieve the trailers or error at most once. It will be success on the first call in which the outer option is `some`, and error on subsequent calls. The inner `result` represents that either the HTTP Request or Response body, as well as any trailers, were received successfully, or that an error occured receiving them. The optional `trailers` indicates whether or not trailers were present in the body. When some `trailers` are returned by this method, the `trailers` resource is immutable, and a child. Use of the `set`, `append`, or `delete` methods will return an error, and the resource must be dropped before the parent `future-trailers` is dropped. """ raise NotImplementedError def __enter__(self) -> Self: """Returns self""" return self def __exit__(self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None) -> bool | None: """ Release this resource. """ raise NotImplementedErrorRepresents a future which may eventaully return trailers, or an error.
In the case that the incoming HTTP Request or Response did not have any trailers, this future will resolve to the empty set of trailers once the complete Request or Response body has been received.
Methods
def get(self) ‑> Ok[Ok[Fields | None] | Err[ErrorCode_DnsTimeout | ErrorCode_DnsError | ErrorCode_DestinationNotFound | ErrorCode_DestinationUnavailable | ErrorCode_DestinationIpProhibited | ErrorCode_DestinationIpUnroutable | ErrorCode_ConnectionRefused | ErrorCode_ConnectionTerminated | ErrorCode_ConnectionTimeout | ErrorCode_ConnectionReadTimeout | ErrorCode_ConnectionWriteTimeout | ErrorCode_ConnectionLimitReached | ErrorCode_TlsProtocolError | ErrorCode_TlsCertificateError | ErrorCode_TlsAlertReceived | ErrorCode_HttpRequestDenied | ErrorCode_HttpRequestLengthRequired | ErrorCode_HttpRequestBodySize | ErrorCode_HttpRequestMethodInvalid | ErrorCode_HttpRequestUriInvalid | ErrorCode_HttpRequestUriTooLong | ErrorCode_HttpRequestHeaderSectionSize | ErrorCode_HttpRequestHeaderSize | ErrorCode_HttpRequestTrailerSectionSize | ErrorCode_HttpRequestTrailerSize | ErrorCode_HttpResponseIncomplete | ErrorCode_HttpResponseHeaderSectionSize | ErrorCode_HttpResponseHeaderSize | ErrorCode_HttpResponseBodySize | ErrorCode_HttpResponseTrailerSectionSize | ErrorCode_HttpResponseTrailerSize | ErrorCode_HttpResponseTransferCoding | ErrorCode_HttpResponseContentCoding | ErrorCode_HttpResponseTimeout | ErrorCode_HttpUpgradeFailed | ErrorCode_HttpProtocolError | ErrorCode_LoopDetected | ErrorCode_ConfigurationError | ErrorCode_InternalError]] | Err[None] | None-
Expand source code
def get(self) -> Optional[Result[Result[Optional[Fields], ErrorCode], None]]: """ Returns the contents of the trailers, or an error which occured, once the future is ready. The outer `option` represents future readiness. Users can wait on this `option` to become `some` using the `subscribe` method. The outer `result` is used to retrieve the trailers or error at most once. It will be success on the first call in which the outer option is `some`, and error on subsequent calls. The inner `result` represents that either the HTTP Request or Response body, as well as any trailers, were received successfully, or that an error occured receiving them. The optional `trailers` indicates whether or not trailers were present in the body. When some `trailers` are returned by this method, the `trailers` resource is immutable, and a child. Use of the `set`, `append`, or `delete` methods will return an error, and the resource must be dropped before the parent `future-trailers` is dropped. """ raise NotImplementedErrorReturns the contents of the trailers, or an error which occured, once the future is ready.
The outer
optionrepresents future readiness. Users can wait on thisoptionto becomesomeusing thesubscribemethod.The outer
resultis used to retrieve the trailers or error at most once. It will be success on the first call in which the outer option issome, and error on subsequent calls.The inner
resultrepresents that either the HTTP Request or Response body, as well as any trailers, were received successfully, or that an error occured receiving them. The optionaltrailersindicates whether or not trailers were present in the body.When some
trailersare returned by this method, thetrailersresource is immutable, and a child. Use of theset,append, ordeletemethods will return an error, and the resource must be dropped before the parentfuture-trailersis dropped. def subscribe(self) ‑> Pollable-
Expand source code
def subscribe(self) -> poll.Pollable: """ Returns a pollable which becomes ready when either the trailers have been received, or an error has occured. When this pollable is ready, the `get` method will return `some`. """ raise NotImplementedErrorReturns a pollable which becomes ready when either the trailers have been received, or an error has occured. When this pollable is ready, the
getmethod will returnsome.
class HeaderError_Forbidden-
Expand source code
@dataclass class HeaderError_Forbidden: passHeaderError_Forbidden()
class HeaderError_Immutable-
Expand source code
@dataclass class HeaderError_Immutable: passHeaderError_Immutable()
class HeaderError_InvalidSyntax-
Expand source code
@dataclass class HeaderError_InvalidSyntax: passHeaderError_InvalidSyntax()
class IncomingBody-
Expand source code
class IncomingBody: """ Represents an incoming HTTP Request or Response's Body. A body has both its contents - a stream of bytes - and a (possibly empty) set of trailers, indicating that the full contents of the body have been received. This resource represents the contents as an `input-stream` and the delivery of trailers as a `future-trailers`, and ensures that the user of this interface may only be consuming either the body contents or waiting on trailers at any given time. """ def stream(self) -> streams.InputStream: """ Returns the contents of the body, as a stream of bytes. Returns success on first call: the stream representing the contents can be retrieved at most once. Subsequent calls will return error. The returned `input-stream` resource is a child: it must be dropped before the parent `incoming-body` is dropped, or consumed by `incoming-body.finish`. This invariant ensures that the implementation can determine whether the user is consuming the contents of the body, waiting on the `future-trailers` to be ready, or neither. This allows for network backpressure is to be applied when the user is consuming the body, and for that backpressure to not inhibit delivery of the trailers if the user does not read the entire body. Raises: `spin_sdk.wit.types.Err(None)` """ raise NotImplementedError @classmethod def finish(cls, this: Self) -> FutureTrailers: """ Takes ownership of `incoming-body`, and returns a `future-trailers`. This function will trap if the `input-stream` child is still alive. """ raise NotImplementedError def __enter__(self) -> Self: """Returns self""" return self def __exit__(self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None) -> bool | None: """ Release this resource. """ raise NotImplementedErrorRepresents an incoming HTTP Request or Response's Body.
A body has both its contents - a stream of bytes - and a (possibly empty) set of trailers, indicating that the full contents of the body have been received. This resource represents the contents as an
input-streamand the delivery of trailers as afuture-trailers, and ensures that the user of this interface may only be consuming either the body contents or waiting on trailers at any given time.Static methods
def finish(this: Self) ‑> FutureTrailers-
Takes ownership of
incoming-body, and returns afuture-trailers. This function will trap if theinput-streamchild is still alive.
Methods
def stream(self) ‑> InputStream-
Expand source code
def stream(self) -> streams.InputStream: """ Returns the contents of the body, as a stream of bytes. Returns success on first call: the stream representing the contents can be retrieved at most once. Subsequent calls will return error. The returned `input-stream` resource is a child: it must be dropped before the parent `incoming-body` is dropped, or consumed by `incoming-body.finish`. This invariant ensures that the implementation can determine whether the user is consuming the contents of the body, waiting on the `future-trailers` to be ready, or neither. This allows for network backpressure is to be applied when the user is consuming the body, and for that backpressure to not inhibit delivery of the trailers if the user does not read the entire body. Raises: `spin_sdk.wit.types.Err(None)` """ raise NotImplementedErrorReturns the contents of the body, as a stream of bytes.
Returns success on first call: the stream representing the contents can be retrieved at most once. Subsequent calls will return error.
The returned
input-streamresource is a child: it must be dropped before the parentincoming-bodyis dropped, or consumed byincoming-body.finish.This invariant ensures that the implementation can determine whether the user is consuming the contents of the body, waiting on the
future-trailersto be ready, or neither. This allows for network backpressure is to be applied when the user is consuming the body, and for that backpressure to not inhibit delivery of the trailers if the user does not read the entire body.Raises:
Err(None)
class IncomingRequest-
Expand source code
class IncomingRequest: """ Represents an incoming HTTP Request. """ def method(self) -> Method: """ Returns the method of the incoming request. """ raise NotImplementedError def path_with_query(self) -> Optional[str]: """ Returns the path with query parameters from the request, as a string. """ raise NotImplementedError def scheme(self) -> Optional[Scheme]: """ Returns the protocol scheme from the request. """ raise NotImplementedError def authority(self) -> Optional[str]: """ Returns the authority from the request, if it was present. """ raise NotImplementedError def headers(self) -> Fields: """ Get the `headers` associated with the request. The returned `headers` resource is immutable: `set`, `append`, and `delete` operations will fail with `header-error.immutable`. The `headers` returned are a child resource: it must be dropped before the parent `incoming-request` is dropped. Dropping this `incoming-request` before all children are dropped will trap. """ raise NotImplementedError def consume(self) -> IncomingBody: """ Gives the `incoming-body` associated with this request. Will only return success at most once, and subsequent calls will return error. Raises: `spin_sdk.wit.types.Err(None)` """ raise NotImplementedError def __enter__(self) -> Self: """Returns self""" return self def __exit__(self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None) -> bool | None: """ Release this resource. """ raise NotImplementedErrorRepresents an incoming HTTP Request.
Methods
-
Expand source code
def authority(self) -> Optional[str]: """ Returns the authority from the request, if it was present. """ raise NotImplementedErrorReturns the authority from the request, if it was present.
def consume(self) ‑> IncomingBody-
Expand source code
def consume(self) -> IncomingBody: """ Gives the `incoming-body` associated with this request. Will only return success at most once, and subsequent calls will return error. Raises: `spin_sdk.wit.types.Err(None)` """ raise NotImplementedErrorGives the
incoming-bodyassociated with this request. Will only return success at most once, and subsequent calls will return error.Raises:
Err(None) def headers(self) ‑> Fields-
Expand source code
def headers(self) -> Fields: """ Get the `headers` associated with the request. The returned `headers` resource is immutable: `set`, `append`, and `delete` operations will fail with `header-error.immutable`. The `headers` returned are a child resource: it must be dropped before the parent `incoming-request` is dropped. Dropping this `incoming-request` before all children are dropped will trap. """ raise NotImplementedErrorGet the
headersassociated with the request.The returned
headersresource is immutable:set,append, anddeleteoperations will fail withheader-error.immutable.The
headersreturned are a child resource: it must be dropped before the parentincoming-requestis dropped. Dropping thisincoming-requestbefore all children are dropped will trap. def method(self) ‑> Method_Get | Method_Head | Method_Post | Method_Put | Method_Delete | Method_Connect | Method_Options | Method_Trace | Method_Patch | Method_Other-
Expand source code
def method(self) -> Method: """ Returns the method of the incoming request. """ raise NotImplementedErrorReturns the method of the incoming request.
def path_with_query(self) ‑> str | None-
Expand source code
def path_with_query(self) -> Optional[str]: """ Returns the path with query parameters from the request, as a string. """ raise NotImplementedErrorReturns the path with query parameters from the request, as a string.
def scheme(self) ‑> Scheme_Http | Scheme_Https | Scheme_Other | None-
Expand source code
def scheme(self) -> Optional[Scheme]: """ Returns the protocol scheme from the request. """ raise NotImplementedErrorReturns the protocol scheme from the request.
-
class IncomingResponse-
Expand source code
class IncomingResponse: """ Represents an incoming HTTP Response. """ def status(self) -> int: """ Returns the status code from the incoming response. """ raise NotImplementedError def headers(self) -> Fields: """ Returns the headers from the incoming response. The returned `headers` resource is immutable: `set`, `append`, and `delete` operations will fail with `header-error.immutable`. This headers resource is a child: it must be dropped before the parent `incoming-response` is dropped. """ raise NotImplementedError def consume(self) -> IncomingBody: """ Returns the incoming body. May be called at most once. Returns error if called additional times. Raises: `spin_sdk.wit.types.Err(None)` """ raise NotImplementedError def __enter__(self) -> Self: """Returns self""" return self def __exit__(self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None) -> bool | None: """ Release this resource. """ raise NotImplementedErrorRepresents an incoming HTTP Response.
Methods
def consume(self) ‑> IncomingBody-
Expand source code
def consume(self) -> IncomingBody: """ Returns the incoming body. May be called at most once. Returns error if called additional times. Raises: `spin_sdk.wit.types.Err(None)` """ raise NotImplementedErrorReturns the incoming body. May be called at most once. Returns error if called additional times.
Raises:
Err(None) def headers(self) ‑> Fields-
Expand source code
def headers(self) -> Fields: """ Returns the headers from the incoming response. The returned `headers` resource is immutable: `set`, `append`, and `delete` operations will fail with `header-error.immutable`. This headers resource is a child: it must be dropped before the parent `incoming-response` is dropped. """ raise NotImplementedErrorReturns the headers from the incoming response.
The returned
headersresource is immutable:set,append, anddeleteoperations will fail withheader-error.immutable.This headers resource is a child: it must be dropped before the parent
incoming-responseis dropped. def status(self) ‑> int-
Expand source code
def status(self) -> int: """ Returns the status code from the incoming response. """ raise NotImplementedErrorReturns the status code from the incoming response.
class Method_Connect-
Expand source code
@dataclass class Method_Connect: passMethod_Connect()
class Method_Delete-
Expand source code
@dataclass class Method_Delete: passMethod_Delete()
class Method_Get-
Expand source code
@dataclass class Method_Get: passMethod_Get()
class Method_Head-
Expand source code
@dataclass class Method_Head: passMethod_Head()
class Method_Options-
Expand source code
@dataclass class Method_Options: passMethod_Options()
class Method_Other (value: str)-
Expand source code
@dataclass class Method_Other: value: strMethod_Other(value: str)
Instance variables
var value : str
class Method_Patch-
Expand source code
@dataclass class Method_Patch: passMethod_Patch()
class Method_Post-
Expand source code
@dataclass class Method_Post: passMethod_Post()
class Method_Put-
Expand source code
@dataclass class Method_Put: passMethod_Put()
class Method_Trace-
Expand source code
@dataclass class Method_Trace: passMethod_Trace()
class OutgoingBody-
Expand source code
class OutgoingBody: """ Represents an outgoing HTTP Request or Response's Body. A body has both its contents - a stream of bytes - and a (possibly empty) set of trailers, inducating the full contents of the body have been sent. This resource represents the contents as an `output-stream` child resource, and the completion of the body (with optional trailers) with a static function that consumes the `outgoing-body` resource, and ensures that the user of this interface may not write to the body contents after the body has been finished. If the user code drops this resource, as opposed to calling the static method `finish`, the implementation should treat the body as incomplete, and that an error has occured. The implementation should propogate this error to the HTTP protocol by whatever means it has available, including: corrupting the body on the wire, aborting the associated Request, or sending a late status code for the Response. """ def write(self) -> streams.OutputStream: """ Returns a stream for writing the body contents. The returned `output-stream` is a child resource: it must be dropped before the parent `outgoing-body` resource is dropped (or finished), otherwise the `outgoing-body` drop or `finish` will trap. Returns success on the first call: the `output-stream` resource for this `outgoing-body` may be retrieved at most once. Subsequent calls will return error. Raises: `spin_sdk.wit.types.Err(None)` """ raise NotImplementedError @classmethod def finish(cls, this: Self, trailers: Optional[Fields]) -> None: """ Finalize an outgoing body, optionally providing trailers. This must be called to signal that the response is complete. If the `outgoing-body` is dropped without calling `outgoing-body.finalize`, the implementation should treat the body as corrupted. Fails if the body's `outgoing-request` or `outgoing-response` was constructed with a Content-Length header, and the contents written to the body (via `write`) does not match the value given in the Content-Length. Raises: `spin_sdk.wit.types.Err(spin_sdk.wit.imports.types.ErrorCode)` """ raise NotImplementedError def __enter__(self) -> Self: """Returns self""" return self def __exit__(self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None) -> bool | None: """ Release this resource. """ raise NotImplementedErrorRepresents an outgoing HTTP Request or Response's Body.
A body has both its contents - a stream of bytes - and a (possibly empty) set of trailers, inducating the full contents of the body have been sent. This resource represents the contents as an
output-streamchild resource, and the completion of the body (with optional trailers) with a static function that consumes theoutgoing-bodyresource, and ensures that the user of this interface may not write to the body contents after the body has been finished.If the user code drops this resource, as opposed to calling the static method
finish, the implementation should treat the body as incomplete, and that an error has occured. The implementation should propogate this error to the HTTP protocol by whatever means it has available, including: corrupting the body on the wire, aborting the associated Request, or sending a late status code for the Response.Static methods
def finish(this: Self,
trailers: Fields | None) ‑> None-
Finalize an outgoing body, optionally providing trailers. This must be called to signal that the response is complete. If the
outgoing-bodyis dropped without callingoutgoing-body.finalize, the implementation should treat the body as corrupted.Fails if the body's
outgoing-requestoroutgoing-responsewas constructed with a Content-Length header, and the contents written to the body (viawrite) does not match the value given in the Content-Length.
Methods
def write(self) ‑> OutputStream-
Expand source code
def write(self) -> streams.OutputStream: """ Returns a stream for writing the body contents. The returned `output-stream` is a child resource: it must be dropped before the parent `outgoing-body` resource is dropped (or finished), otherwise the `outgoing-body` drop or `finish` will trap. Returns success on the first call: the `output-stream` resource for this `outgoing-body` may be retrieved at most once. Subsequent calls will return error. Raises: `spin_sdk.wit.types.Err(None)` """ raise NotImplementedErrorReturns a stream for writing the body contents.
The returned
output-streamis a child resource: it must be dropped before the parentoutgoing-bodyresource is dropped (or finished), otherwise theoutgoing-bodydrop orfinishwill trap.Returns success on the first call: the
output-streamresource for thisoutgoing-bodymay be retrieved at most once. Subsequent calls will return error.Raises:
Err(None)
class OutgoingRequest (headers: Fields)-
Expand source code
class OutgoingRequest: """ Represents an outgoing HTTP Request. """ def __init__(self, headers: Fields) -> None: """ Construct a new `outgoing-request` with a default `method` of `GET`, and `none` values for `path-with-query`, `scheme`, and `authority`. * `headers` is the HTTP Headers for the Request. It is possible to construct, or manipulate with the accessor functions below, an `outgoing-request` with an invalid combination of `scheme` and `authority`, or `headers` which are not permitted to be sent. It is the obligation of the `outgoing-handler.handle` implementation to reject invalid constructions of `outgoing-request`. """ raise NotImplementedError def body(self) -> OutgoingBody: """ Returns the resource corresponding to the outgoing Body for this Request. Returns success on the first call: the `outgoing-body` resource for this `outgoing-request` can be retrieved at most once. Subsequent calls will return error. Raises: `spin_sdk.wit.types.Err(None)` """ raise NotImplementedError def method(self) -> Method: """ Get the Method for the Request. """ raise NotImplementedError def set_method(self, method: Method) -> None: """ Set the Method for the Request. Fails if the string present in a `method.other` argument is not a syntactically valid method. Raises: `spin_sdk.wit.types.Err(None)` """ raise NotImplementedError def path_with_query(self) -> Optional[str]: """ Get the combination of the HTTP Path and Query for the Request. When `none`, this represents an empty Path and empty Query. """ raise NotImplementedError def set_path_with_query(self, path_with_query: Optional[str]) -> None: """ Set the combination of the HTTP Path and Query for the Request. When `none`, this represents an empty Path and empty Query. Fails is the string given is not a syntactically valid path and query uri component. Raises: `spin_sdk.wit.types.Err(None)` """ raise NotImplementedError def scheme(self) -> Optional[Scheme]: """ Get the HTTP Related Scheme for the Request. When `none`, the implementation may choose an appropriate default scheme. """ raise NotImplementedError def set_scheme(self, scheme: Optional[Scheme]) -> None: """ Set the HTTP Related Scheme for the Request. When `none`, the implementation may choose an appropriate default scheme. Fails if the string given is not a syntactically valid uri scheme. Raises: `spin_sdk.wit.types.Err(None)` """ raise NotImplementedError def authority(self) -> Optional[str]: """ Get the HTTP Authority for the Request. A value of `none` may be used with Related Schemes which do not require an Authority. The HTTP and HTTPS schemes always require an authority. """ raise NotImplementedError def set_authority(self, authority: Optional[str]) -> None: """ Set the HTTP Authority for the Request. A value of `none` may be used with Related Schemes which do not require an Authority. The HTTP and HTTPS schemes always require an authority. Fails if the string given is not a syntactically valid uri authority. Raises: `spin_sdk.wit.types.Err(None)` """ raise NotImplementedError def headers(self) -> Fields: """ Get the headers associated with the Request. The returned `headers` resource is immutable: `set`, `append`, and `delete` operations will fail with `header-error.immutable`. This headers resource is a child: it must be dropped before the parent `outgoing-request` is dropped, or its ownership is transfered to another component by e.g. `outgoing-handler.handle`. """ raise NotImplementedError def __enter__(self) -> Self: """Returns self""" return self def __exit__(self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None) -> bool | None: """ Release this resource. """ raise NotImplementedErrorRepresents an outgoing HTTP Request.
Construct a new
outgoing-requestwith a defaultmethodofGET, andnonevalues forpath-with-query,scheme, andauthority.headersis the HTTP Headers for the Request.
It is possible to construct, or manipulate with the accessor functions below, an
outgoing-requestwith an invalid combination ofschemeandauthority, orheaderswhich are not permitted to be sent. It is the obligation of theoutgoing-handler.handleimplementation to reject invalid constructions ofoutgoing-request.Methods
-
Expand source code
def authority(self) -> Optional[str]: """ Get the HTTP Authority for the Request. A value of `none` may be used with Related Schemes which do not require an Authority. The HTTP and HTTPS schemes always require an authority. """ raise NotImplementedErrorGet the HTTP Authority for the Request. A value of
nonemay be used with Related Schemes which do not require an Authority. The HTTP and HTTPS schemes always require an authority. def body(self) ‑> OutgoingBody-
Expand source code
def body(self) -> OutgoingBody: """ Returns the resource corresponding to the outgoing Body for this Request. Returns success on the first call: the `outgoing-body` resource for this `outgoing-request` can be retrieved at most once. Subsequent calls will return error. Raises: `spin_sdk.wit.types.Err(None)` """ raise NotImplementedErrorReturns the resource corresponding to the outgoing Body for this Request.
Returns success on the first call: the
outgoing-bodyresource for thisoutgoing-requestcan be retrieved at most once. Subsequent calls will return error.Raises:
Err(None) def headers(self) ‑> Fields-
Expand source code
def headers(self) -> Fields: """ Get the headers associated with the Request. The returned `headers` resource is immutable: `set`, `append`, and `delete` operations will fail with `header-error.immutable`. This headers resource is a child: it must be dropped before the parent `outgoing-request` is dropped, or its ownership is transfered to another component by e.g. `outgoing-handler.handle`. """ raise NotImplementedErrorGet the headers associated with the Request.
The returned
headersresource is immutable:set,append, anddeleteoperations will fail withheader-error.immutable.This headers resource is a child: it must be dropped before the parent
outgoing-requestis dropped, or its ownership is transfered to another component by e.g.outgoing-handler.handle. def method(self) ‑> Method_Get | Method_Head | Method_Post | Method_Put | Method_Delete | Method_Connect | Method_Options | Method_Trace | Method_Patch | Method_Other-
Expand source code
def method(self) -> Method: """ Get the Method for the Request. """ raise NotImplementedErrorGet the Method for the Request.
def path_with_query(self) ‑> str | None-
Expand source code
def path_with_query(self) -> Optional[str]: """ Get the combination of the HTTP Path and Query for the Request. When `none`, this represents an empty Path and empty Query. """ raise NotImplementedErrorGet the combination of the HTTP Path and Query for the Request. When
none, this represents an empty Path and empty Query. def scheme(self) ‑> Scheme_Http | Scheme_Https | Scheme_Other | None-
Expand source code
def scheme(self) -> Optional[Scheme]: """ Get the HTTP Related Scheme for the Request. When `none`, the implementation may choose an appropriate default scheme. """ raise NotImplementedErrorGet the HTTP Related Scheme for the Request. When
none, the implementation may choose an appropriate default scheme. -
Expand source code
def set_authority(self, authority: Optional[str]) -> None: """ Set the HTTP Authority for the Request. A value of `none` may be used with Related Schemes which do not require an Authority. The HTTP and HTTPS schemes always require an authority. Fails if the string given is not a syntactically valid uri authority. Raises: `spin_sdk.wit.types.Err(None)` """ raise NotImplementedErrorSet the HTTP Authority for the Request. A value of
nonemay be used with Related Schemes which do not require an Authority. The HTTP and HTTPS schemes always require an authority. Fails if the string given is not a syntactically valid uri authority.Raises:
Err(None) def set_method(self,
method: Method_Get | Method_Head | Method_Post | Method_Put | Method_Delete | Method_Connect | Method_Options | Method_Trace | Method_Patch | Method_Other) ‑> None-
Expand source code
def set_method(self, method: Method) -> None: """ Set the Method for the Request. Fails if the string present in a `method.other` argument is not a syntactically valid method. Raises: `spin_sdk.wit.types.Err(None)` """ raise NotImplementedErrorSet the Method for the Request. Fails if the string present in a
method.otherargument is not a syntactically valid method.Raises:
Err(None) def set_path_with_query(self, path_with_query: str | None) ‑> None-
Expand source code
def set_path_with_query(self, path_with_query: Optional[str]) -> None: """ Set the combination of the HTTP Path and Query for the Request. When `none`, this represents an empty Path and empty Query. Fails is the string given is not a syntactically valid path and query uri component. Raises: `spin_sdk.wit.types.Err(None)` """ raise NotImplementedErrorSet the combination of the HTTP Path and Query for the Request. When
none, this represents an empty Path and empty Query. Fails is the string given is not a syntactically valid path and query uri component.Raises:
Err(None) def set_scheme(self,
scheme: Scheme_Http | Scheme_Https | Scheme_Other | None) ‑> None-
Expand source code
def set_scheme(self, scheme: Optional[Scheme]) -> None: """ Set the HTTP Related Scheme for the Request. When `none`, the implementation may choose an appropriate default scheme. Fails if the string given is not a syntactically valid uri scheme. Raises: `spin_sdk.wit.types.Err(None)` """ raise NotImplementedErrorSet the HTTP Related Scheme for the Request. When
none, the implementation may choose an appropriate default scheme. Fails if the string given is not a syntactically valid uri scheme.Raises:
Err(None)
class OutgoingResponse (headers: Fields)-
Expand source code
class OutgoingResponse: """ Represents an outgoing HTTP Response. """ def __init__(self, headers: Fields) -> None: """ Construct an `outgoing-response`, with a default `status-code` of `200`. If a different `status-code` is needed, it must be set via the `set-status-code` method. * `headers` is the HTTP Headers for the Response. """ raise NotImplementedError def status_code(self) -> int: """ Get the HTTP Status Code for the Response. """ raise NotImplementedError def set_status_code(self, status_code: int) -> None: """ Set the HTTP Status Code for the Response. Fails if the status-code given is not a valid http status code. Raises: `spin_sdk.wit.types.Err(None)` """ raise NotImplementedError def headers(self) -> Fields: """ Get the headers associated with the Request. The returned `headers` resource is immutable: `set`, `append`, and `delete` operations will fail with `header-error.immutable`. This headers resource is a child: it must be dropped before the parent `outgoing-request` is dropped, or its ownership is transfered to another component by e.g. `outgoing-handler.handle`. """ raise NotImplementedError def body(self) -> OutgoingBody: """ Returns the resource corresponding to the outgoing Body for this Response. Returns success on the first call: the `outgoing-body` resource for this `outgoing-response` can be retrieved at most once. Subsequent calls will return error. Raises: `spin_sdk.wit.types.Err(None)` """ raise NotImplementedError def __enter__(self) -> Self: """Returns self""" return self def __exit__(self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None) -> bool | None: """ Release this resource. """ raise NotImplementedErrorRepresents an outgoing HTTP Response.
Construct an
outgoing-response, with a defaultstatus-codeof200. If a differentstatus-codeis needed, it must be set via theset-status-codemethod.headersis the HTTP Headers for the Response.
Methods
def body(self) ‑> OutgoingBody-
Expand source code
def body(self) -> OutgoingBody: """ Returns the resource corresponding to the outgoing Body for this Response. Returns success on the first call: the `outgoing-body` resource for this `outgoing-response` can be retrieved at most once. Subsequent calls will return error. Raises: `spin_sdk.wit.types.Err(None)` """ raise NotImplementedErrorReturns the resource corresponding to the outgoing Body for this Response.
Returns success on the first call: the
outgoing-bodyresource for thisoutgoing-responsecan be retrieved at most once. Subsequent calls will return error.Raises:
Err(None) def headers(self) ‑> Fields-
Expand source code
def headers(self) -> Fields: """ Get the headers associated with the Request. The returned `headers` resource is immutable: `set`, `append`, and `delete` operations will fail with `header-error.immutable`. This headers resource is a child: it must be dropped before the parent `outgoing-request` is dropped, or its ownership is transfered to another component by e.g. `outgoing-handler.handle`. """ raise NotImplementedErrorGet the headers associated with the Request.
The returned
headersresource is immutable:set,append, anddeleteoperations will fail withheader-error.immutable.This headers resource is a child: it must be dropped before the parent
outgoing-requestis dropped, or its ownership is transfered to another component by e.g.outgoing-handler.handle. def set_status_code(self, status_code: int) ‑> None-
Expand source code
def set_status_code(self, status_code: int) -> None: """ Set the HTTP Status Code for the Response. Fails if the status-code given is not a valid http status code. Raises: `spin_sdk.wit.types.Err(None)` """ raise NotImplementedErrorSet the HTTP Status Code for the Response. Fails if the status-code given is not a valid http status code.
Raises:
Err(None) def status_code(self) ‑> int-
Expand source code
def status_code(self) -> int: """ Get the HTTP Status Code for the Response. """ raise NotImplementedErrorGet the HTTP Status Code for the Response.
class RequestOptions-
Expand source code
class RequestOptions: """ Parameters for making an HTTP Request. Each of these parameters is currently an optional timeout applicable to the transport layer of the HTTP protocol. These timeouts are separate from any the user may use to bound a blocking call to `wasi:io/poll.poll`. """ def __init__(self) -> None: """ Construct a default `request-options` value. """ raise NotImplementedError def connect_timeout(self) -> Optional[int]: """ The timeout for the initial connect to the HTTP Server. """ raise NotImplementedError def set_connect_timeout(self, duration: Optional[int]) -> None: """ Set the timeout for the initial connect to the HTTP Server. An error return value indicates that this timeout is not supported. Raises: `spin_sdk.wit.types.Err(None)` """ raise NotImplementedError def first_byte_timeout(self) -> Optional[int]: """ The timeout for receiving the first byte of the Response body. """ raise NotImplementedError def set_first_byte_timeout(self, duration: Optional[int]) -> None: """ Set the timeout for receiving the first byte of the Response body. An error return value indicates that this timeout is not supported. Raises: `spin_sdk.wit.types.Err(None)` """ raise NotImplementedError def between_bytes_timeout(self) -> Optional[int]: """ The timeout for receiving subsequent chunks of bytes in the Response body stream. """ raise NotImplementedError def set_between_bytes_timeout(self, duration: Optional[int]) -> None: """ Set the timeout for receiving subsequent chunks of bytes in the Response body stream. An error return value indicates that this timeout is not supported. Raises: `spin_sdk.wit.types.Err(None)` """ raise NotImplementedError def __enter__(self) -> Self: """Returns self""" return self def __exit__(self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None) -> bool | None: """ Release this resource. """ raise NotImplementedErrorParameters for making an HTTP Request. Each of these parameters is currently an optional timeout applicable to the transport layer of the HTTP protocol.
These timeouts are separate from any the user may use to bound a blocking call to
wasi:io/poll.poll.Construct a default
request-optionsvalue.Methods
def between_bytes_timeout(self) ‑> int | None-
Expand source code
def between_bytes_timeout(self) -> Optional[int]: """ The timeout for receiving subsequent chunks of bytes in the Response body stream. """ raise NotImplementedErrorThe timeout for receiving subsequent chunks of bytes in the Response body stream.
def connect_timeout(self) ‑> int | None-
Expand source code
def connect_timeout(self) -> Optional[int]: """ The timeout for the initial connect to the HTTP Server. """ raise NotImplementedErrorThe timeout for the initial connect to the HTTP Server.
def first_byte_timeout(self) ‑> int | None-
Expand source code
def first_byte_timeout(self) -> Optional[int]: """ The timeout for receiving the first byte of the Response body. """ raise NotImplementedErrorThe timeout for receiving the first byte of the Response body.
def set_between_bytes_timeout(self, duration: int | None) ‑> None-
Expand source code
def set_between_bytes_timeout(self, duration: Optional[int]) -> None: """ Set the timeout for receiving subsequent chunks of bytes in the Response body stream. An error return value indicates that this timeout is not supported. Raises: `spin_sdk.wit.types.Err(None)` """ raise NotImplementedErrorSet the timeout for receiving subsequent chunks of bytes in the Response body stream. An error return value indicates that this timeout is not supported.
Raises:
Err(None) def set_connect_timeout(self, duration: int | None) ‑> None-
Expand source code
def set_connect_timeout(self, duration: Optional[int]) -> None: """ Set the timeout for the initial connect to the HTTP Server. An error return value indicates that this timeout is not supported. Raises: `spin_sdk.wit.types.Err(None)` """ raise NotImplementedErrorSet the timeout for the initial connect to the HTTP Server. An error return value indicates that this timeout is not supported.
Raises:
Err(None) def set_first_byte_timeout(self, duration: int | None) ‑> None-
Expand source code
def set_first_byte_timeout(self, duration: Optional[int]) -> None: """ Set the timeout for receiving the first byte of the Response body. An error return value indicates that this timeout is not supported. Raises: `spin_sdk.wit.types.Err(None)` """ raise NotImplementedErrorSet the timeout for receiving the first byte of the Response body. An error return value indicates that this timeout is not supported.
Raises:
Err(None)
class ResponseOutparam-
Expand source code
class ResponseOutparam: """ Represents the ability to send an HTTP Response. This resource is used by the `wasi:http/incoming-handler` interface to allow a Response to be sent corresponding to the Request provided as the other argument to `incoming-handler.handle`. """ @classmethod def set(cls, param: Self, response: Result[OutgoingResponse, ErrorCode]) -> None: """ Set the value of the `response-outparam` to either send a response, or indicate an error. This method consumes the `response-outparam` to ensure that it is called at most once. If it is never called, the implementation will respond with an error. The user may provide an `error` to `response` to allow the implementation determine how to respond with an HTTP error response. """ raise NotImplementedError def __enter__(self) -> Self: """Returns self""" return self def __exit__(self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None) -> bool | None: """ Release this resource. """ raise NotImplementedErrorRepresents the ability to send an HTTP Response.
This resource is used by the
wasi:http/incoming-handlerinterface to allow a Response to be sent corresponding to the Request provided as the other argument toincoming-handler.handle.Static methods
def set(param: Self,
response: Ok[OutgoingResponse] | Err[ErrorCode_DnsTimeout | ErrorCode_DnsError | ErrorCode_DestinationNotFound | ErrorCode_DestinationUnavailable | ErrorCode_DestinationIpProhibited | ErrorCode_DestinationIpUnroutable | ErrorCode_ConnectionRefused | ErrorCode_ConnectionTerminated | ErrorCode_ConnectionTimeout | ErrorCode_ConnectionReadTimeout | ErrorCode_ConnectionWriteTimeout | ErrorCode_ConnectionLimitReached | ErrorCode_TlsProtocolError | ErrorCode_TlsCertificateError | ErrorCode_TlsAlertReceived | ErrorCode_HttpRequestDenied | ErrorCode_HttpRequestLengthRequired | ErrorCode_HttpRequestBodySize | ErrorCode_HttpRequestMethodInvalid | ErrorCode_HttpRequestUriInvalid | ErrorCode_HttpRequestUriTooLong | ErrorCode_HttpRequestHeaderSectionSize | ErrorCode_HttpRequestHeaderSize | ErrorCode_HttpRequestTrailerSectionSize | ErrorCode_HttpRequestTrailerSize | ErrorCode_HttpResponseIncomplete | ErrorCode_HttpResponseHeaderSectionSize | ErrorCode_HttpResponseHeaderSize | ErrorCode_HttpResponseBodySize | ErrorCode_HttpResponseTrailerSectionSize | ErrorCode_HttpResponseTrailerSize | ErrorCode_HttpResponseTransferCoding | ErrorCode_HttpResponseContentCoding | ErrorCode_HttpResponseTimeout | ErrorCode_HttpUpgradeFailed | ErrorCode_HttpProtocolError | ErrorCode_LoopDetected | ErrorCode_ConfigurationError | ErrorCode_InternalError]) ‑> None-
Set the value of the
response-outparamto either send a response, or indicate an error.This method consumes the
response-outparamto ensure that it is called at most once. If it is never called, the implementation will respond with an error.The user may provide an
errortoresponseto allow the implementation determine how to respond with an HTTP error response.
class Scheme_Http-
Expand source code
@dataclass class Scheme_Http: passScheme_Http()
class Scheme_Https-
Expand source code
@dataclass class Scheme_Https: passScheme_Https()
class Scheme_Other (value: str)-
Expand source code
@dataclass class Scheme_Other: value: strScheme_Other(value: str)
Instance variables
var value : str
class TlsAlertReceivedPayload (alert_id: int | None, alert_message: str | None)-
Expand source code
@dataclass class TlsAlertReceivedPayload: """ Defines the case payload type for `TLS-alert-received` above: """ alert_id: Optional[int] alert_message: Optional[str]Defines the case payload type for
TLS-alert-receivedabove:Instance variables
var alert_id : int | Nonevar alert_message : str | None