pub struct HTTPLibrary {
pub agent: Agent,
}
Fields§
§agent: Agent
Trait Implementations§
Source§impl Debug for HTTPLibrary
impl Debug for HTTPLibrary
Source§impl Default for HTTPLibrary
impl Default for HTTPLibrary
Source§impl Library for HTTPLibrary
impl Library for HTTPLibrary
Source§fn scope(&self) -> String
fn scope(&self) -> String
Scope of this library.
This is how this library is invoked from Stof.
Ex. HTTP.get('https://example.com')
Source§fn call(
&self,
pid: &str,
doc: &mut SDoc,
name: &str,
parameters: &mut Vec<SVal>,
) -> Result<SVal, SError>
fn call( &self, pid: &str, doc: &mut SDoc, name: &str, parameters: &mut Vec<SVal>, ) -> Result<SVal, SError>
Call an HTTP method in this library.
Supported functions:
- HTTP.get
- HTTP.head
- HTTP.patch
- HTTP.post
- HTTP.put
- HTTP.delete
Parameters (in order) for each call:
- url: str - The HTTP request path (REQUIRED)
- headers: vec[(str, str)] | map - The request headers (OPTIONAL)
- body: str | blob - The request body (OPTIONAL)
- timeout: float | units - The overall timeout for the request (OPTIONAL) (default 5 seconds - use time units as needed)
- response_obj: obj - A response object to parse the response into via doc.header_import with the content type (OPTIONAL)
Basic GET request: HTTP.get('https://example.com')
POST request with a body: HTTP.post('https://example.com', 'this is a string body to send')
POST request json body and a timeout: HTTP.post('https://example.com', map(('content-type', 'application/json')), stringify(self, 'json'), 10s)
Auto Trait Implementations§
impl Freeze for HTTPLibrary
impl !RefUnwindSafe for HTTPLibrary
impl Send for HTTPLibrary
impl Sync for HTTPLibrary
impl Unpin for HTTPLibrary
impl !UnwindSafe for HTTPLibrary
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more