Module hyper

Low-level HTTP/1 and HTTP/2 implementation for the tokio ecosystem.


hyper is the HTTP implementation underlying axum, reqwest, and other Rust HTTP libraries. Most applications should use those higher-level crates; use hyper directly when you need fine-grained control over HTTP connections or are building your own HTTP framework.

Core types (re-exported from the http crate):

Examples

Working with HTTP request and response types:

use hyper::{Request, Response, Method, StatusCode};

let req = Request::builder()
    .method(Method::POST)
    .uri("https://example.com/api")
    .header("Content-Type", "application/json")
    .body(())
    .unwrap();

assert_eq!(req.method(), Method::POST);
assert_eq!(req.uri(), "https://example.com/api");

let resp = Response::builder()
    .status(StatusCode::OK)
    .header("Content-Type", "text/plain")
    .body(())
    .unwrap();

assert_eq!(resp.status(), StatusCode::OK);

Modules