spin_sdk::http

Struct OutgoingRequest

Source
pub struct OutgoingRequest { /* private fields */ }
Expand description

Represents an outgoing HTTP Request.

Implementations§

Source§

impl OutgoingRequest

Source

pub fn new(headers: Headers) -> Self

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.

Source§

impl OutgoingRequest

Source

pub fn body(&self) -> Result<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.

Source§

impl OutgoingRequest

Source

pub fn method(&self) -> Method

Get the Method for the Request.

Source§

impl OutgoingRequest

Source

pub fn set_method(&self, method: &Method) -> Result<(), ()>

Set the Method for the Request. Fails if the string present in a method.other argument is not a syntactically valid method.

Source§

impl OutgoingRequest

Source

pub fn path_with_query(&self) -> Option<String>

Get the combination of the HTTP Path and Query for the Request. When none, this represents an empty Path and empty Query.

Source§

impl OutgoingRequest

Source

pub fn set_path_with_query( &self, path_with_query: Option<&str>, ) -> Result<(), ()>

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.

Source§

impl OutgoingRequest

Source

pub fn scheme(&self) -> Option<Scheme>

Get the HTTP Related Scheme for the Request. When none, the implementation may choose an appropriate default scheme.

Source§

impl OutgoingRequest

Source

pub fn set_scheme(&self, scheme: Option<&Scheme>) -> Result<(), ()>

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.

Source§

impl OutgoingRequest

Source

pub fn authority(&self) -> Option<String>

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.

Source§

impl OutgoingRequest

Source

pub fn set_authority(&self, authority: Option<&str>) -> Result<(), ()>

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.

Source§

impl OutgoingRequest

Source

pub fn headers(&self) -> Headers

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.

Source§

impl OutgoingRequest

Source

pub fn take_body(&self) -> impl Sink<Vec<u8>, Error = StreamError>

Construct a Sink which writes chunks to the body of the specified response.

§Panics

Panics if the body was already taken.

Trait Implementations§

Source§

impl Debug for OutgoingRequest

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl TryIntoOutgoingRequest for OutgoingRequest

Source§

type Error = Infallible

The error if the conversion fails
Source§

fn try_into_outgoing_request( self, ) -> Result<(OutgoingRequest, Option<Vec<u8>>), Self::Error>

Turn the type into an OutgoingRequest Read more
Source§

impl WasmResource for OutgoingRequest

Source§

unsafe fn drop(_handle: u32)

Invokes the [resource-drop]... intrinsic.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.