Module response
HTTP response types.
This module contains structs related to HTTP responses, notably the
Response type itself as well as a builder to create responses. Typically
you'll import the http::Response type rather than reaching into this
module itself.
Examples
Creating a Response to return
use ;
A simple 404 handler
use ;
Or otherwise inspecting the result of a request:
use http::{Request, Response};
fn get(url: &str) -> http::Result<Response<()>> {
// ...
# panic!()
}
let response = get("https://www.rust-lang.org/").unwrap();
if !response.status().is_success() {
panic!("failed to get a successful response status!");
}
if let Some(date) = response.headers().get("Date") {
// we've got a `Date` header!
}
let body = response.body();
// ...