Module request
HTTP request types.
This module contains structs related to HTTP requests, notably the
Request type itself as well as a builder to create requests. Typically
you'll import the http::Request type rather than reaching into this
module itself.
Examples
Creating a Request to send
use http::{Request, Response};
let mut request = Request::builder()
.uri("https://www.rust-lang.org/")
.header("User-Agent", "my-awesome-agent/1.0");
if needs_awesome_header() {
request = request.header("Awesome", "yes");
}
let response = send(request.body(()).unwrap());
# fn needs_awesome_header() -> bool {
# true
# }
#
fn send(req: Request<()>) -> Response<()> {
// ...
# panic!()
}
Inspecting a request to see what was sent.
use ;