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: RequestLine

The request line of the request.

headers: Headers

The headers of the request.

body: Option<Body>

The body of the request.

files: Vec<File>

The optional files associated with the request.

Implementations

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 “ CRLF”- Optional
* Empty Line “CRLF”
* Entity Body - Optional
The request headers and the entity body are not parsed and None is returned because these are not used by the MMDS server. The only supported method is GET and the HTTP protocol is expected to be HTTP/1.0 or HTTP/1.1.

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();

Returns the Uri from the parsed Request.

The return value can be used to get the absolute path of the URI.

Returns the HTTP Version of the Request.

Returns the HTTP Method of the Request.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.