⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

HttpClient

Struct HttpClient 

Source
pub struct HttpClient {
    pub default_headers: BTreeMap<String, String>,
    pub timeout_ms: u64,
    pub max_redirects: u8,
}
Expand description

HTTP client with configurable defaults.

The client does not perform actual I/O. Instead, prepare_request() returns serialized bytes to send over TCP, and parse_response() accepts received bytes and returns an HttpResponse when complete.

Fields§

§default_headers: BTreeMap<String, String>

Default headers applied to every request.

§timeout_ms: u64

Request timeout in milliseconds.

§max_redirects: u8

Maximum number of redirects to follow.

Implementations§

Source§

impl HttpClient

Source

pub fn new() -> Self

Create a new HTTP client with default settings.

Source

pub fn set_default_header(&mut self, name: &str, value: &str)

Set a default header that will be applied to every request.

Source

pub fn prepare_request(&self, request: &mut HttpRequest) -> Vec<u8>

Prepare a request: apply default headers and serialize to bytes.

Source

pub fn create_parser(&self) -> ResponseParser

Create a new response parser for receiving response data.

Source

pub fn get(&self, url: &str) -> Result<Vec<u8>, HttpError>

Convenience: build and serialize a GET request.

Source

pub fn post( &self, url: &str, body: &[u8], content_type: &str, ) -> Result<Vec<u8>, HttpError>

Convenience: build and serialize a POST request with a body.

Source

pub fn follow_redirect( &self, response: &HttpResponse, original_url: &str, remaining_redirects: &mut u8, ) -> Result<Option<HttpRequest>, HttpError>

Process a redirect response: returns a new request to the redirect location, or None if not a redirect. Decrements remaining_redirects.

Trait Implementations§

Source§

impl Default for HttpClient

Available on crate feature alloc only.
Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for HttpClient

§

impl RefUnwindSafe for HttpClient

§

impl Send for HttpClient

§

impl Sync for HttpClient

§

impl Unpin for HttpClient

§

impl UnwindSafe for HttpClient

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.