pub struct Request(_);
Expand description
Request object.
Can be constructed from a HREQUEST
handle only:
fn on_data_load(pnm: &mut SCN_LOAD_DATA) -> Option<LOAD_RESULT> {
let mut rq = Request::from(pnm.request_id);
// ...
}
Implementations
sourceimpl Request
impl Request
sourcepub fn succeeded(&mut self, status: u32, data: Option<&[u8]>) -> Result<()>
pub fn succeeded(&mut self, status: u32, data: Option<&[u8]>) -> Result<()>
Mark the request as complete with status and optional data.
sourcepub fn failed(&mut self, status: u32, data: Option<&[u8]>) -> Result<()>
pub fn failed(&mut self, status: u32, data: Option<&[u8]>) -> Result<()>
Mark the request as complete with failure.
sourcepub fn append_received_data(&mut self, data: &[u8]) -> Result<()>
pub fn append_received_data(&mut self, data: &[u8]) -> Result<()>
Append a data chunk to the received data.
sourcepub fn get_received_data(&self) -> Result<Vec<u8>>
pub fn get_received_data(&self) -> Result<Vec<u8>>
Get received (so far) data.
sourcepub fn content_url(&self) -> Result<String>
pub fn content_url(&self) -> Result<String>
Get a real URL of the content (e.g., after possible redirection).
sourcepub fn method(&self) -> Result<REQUEST_METHOD>
pub fn method(&self) -> Result<REQUEST_METHOD>
Get the data type of the request.
sourcepub fn request_type(&self) -> Result<RESOURCE_TYPE>
pub fn request_type(&self) -> Result<RESOURCE_TYPE>
Get the resource data type of the request.
sourcepub fn response_type(&self) -> Result<String>
pub fn response_type(&self) -> Result<String>
Get the MIME type of the received data.
sourcepub fn set_response_type(&mut self, mime_type: &str) -> Result<()>
pub fn set_response_type(&mut self, mime_type: &str) -> Result<()>
Set the MIME type of the received data.
sourcepub fn set_response_encoding(&mut self, encoding_type: &str) -> Result<()>
pub fn set_response_encoding(&mut self, encoding_type: &str) -> Result<()>
Set the data encoding for the received data.
sourcepub fn request_headers(&self) -> Result<HashMap<String, String>>
pub fn request_headers(&self) -> Result<HashMap<String, String>>
Get the headers of the request.
sourcepub fn set_request_header(&mut self, name: &str, value: &str) -> Result<()>
pub fn set_request_header(&mut self, name: &str, value: &str) -> Result<()>
Set request header (a single item).
sourcepub fn response_headers(&self) -> Result<HashMap<String, String>>
pub fn response_headers(&self) -> Result<HashMap<String, String>>
Get the headers of the response.
sourcepub fn set_response_header(&mut self, name: &str, value: &str) -> Result<()>
pub fn set_response_header(&mut self, name: &str, value: &str) -> Result<()>
Set respone header (a single item).
sourcepub fn completion_status(&self) -> Result<(REQUEST_STATE, u32)>
pub fn completion_status(&self) -> Result<(REQUEST_STATE, u32)>
Get the current completion status of the request.
Returns current state and HTTP response code.
sourcepub fn request_duration(&self) -> Result<Duration>
pub fn request_duration(&self) -> Result<Duration>
Get the execution duratiom of the request.
Trait Implementations
sourceimpl Clone for Request
impl Clone for Request
Copies the object.
All allocated objects are reference counted so copying is just a matter of increasing reference counts.
Auto Trait Implementations
impl RefUnwindSafe for Request
impl !Send for Request
impl !Sync for Request
impl Unpin for Request
impl UnwindSafe for Request
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more