Skip to main content

HTTP client

You can use the http namespace of the Runnable API to make HTTP requests from your Runnable code. These methods are currently the only way to access the network from Runnable code.

Arbitrary socket and network access is not currently possible.

In Rust these methods are available under the http module:

# Use the "http" module
use suborbital::http;

# Invoke the "Get" method
http::get()

The following namespace methods are available:

GET

Performs an HTTP GET request:

STATUS: STABLE
pub fn get(url: &str, headers: Option<BTreeMap<&str, &str>>) -> Result<Vec<u8>, RunErr>

Performs an HTTP HEAD request:

STATUS: STABLE
pub fn get(url: &str, headers: Option<BTreeMap<&str, &str>>) -> Result<Vec<u8>, HostErr>

OPTIONS

Performs an HTTP OPTIONS request:

STATUS: STABLE
pub fn options(url: &str, headers: Option<BTreeMap<&str, &str>>) -> Result<Vec<u8>, HostErr>

POST

Performs an HTTP POST request:

STATUS: STABLE
pub fn post(url: &str, body: Option<Vec<u8>>, headers: Option<BTreeMap<&str, &str>>) -> Result<Vec<u8>, RunErr>

PUT

Performs an HTTP PUT request:

STATUS: STABLE
pub fn put(url: &str, body: Option<Vec<u8>>, headers: Option<BTreeMap<&str, &str>>) -> Result<Vec<u8>, HostErr>

PATCH

Performs an HTTP PATCH request:

STATUS: STABLE
pub fn patch(url: &str, body: Option<Vec<u8>>, headers: Option<BTreeMap<&str, &str>>) -> Result<Vec<u8>, RunErr>

DELETE

Performs an HTTP DELETE request:

STATUS: STABLE
pub fn delete(url: &str, headers: Option<BTreeMap<&str, &str>>) -> Result<Vec<u8>, RunErr>