pub struct Request {
pub request_line: RequestLine,
pub headers: Headers,
pub body: Option<Body>,
pub files: Vec<File>,
}Expand description
Wrapper over an HTTP Request.
Fields
request_line: RequestLineThe request line of the request.
headers: HeadersThe headers of the request.
body: Option<Body>The body of the request.
files: Vec<File>The optional files associated with the request.
Implementations
sourceimpl Request
impl Request
sourcepub fn try_from(
byte_stream: &[u8],
max_len: Option<usize>
) -> Result<Self, RequestError>
pub fn try_from(
byte_stream: &[u8],
max_len: Option<usize>
) -> Result<Self, RequestError>
Parses a byte slice into a HTTP Request.
The byte slice is expected to have the following format:
* Request Line: “GET SP Request-uri SP HTTP/1.0 CRLF” - Mandatory
* Request Headers “
Errors
The function returns InvalidRequest when parsing the byte stream fails.
Examples
use dbs_uhttp::Request;
let max_request_len = 2000;
let request_bytes = b"GET http://localhost/home HTTP/1.0\r\n\r\n";
let http_request = Request::try_from(request_bytes, Some(max_request_len)).unwrap();sourcepub fn uri(&self) -> &Uri
pub fn uri(&self) -> &Uri
Returns the Uri from the parsed Request.
The return value can be used to get the absolute path of the URI.
sourcepub fn http_version(&self) -> Version
pub fn http_version(&self) -> Version
Returns the HTTP Version of the Request.
Trait Implementations
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 · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more