http

The shared Rust crate defining Request, Response, and other core HTTP types

Library
Cargo
v1.5.0
1,384 stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
75 /100 Good
Development Activity 64
Maintenance 48
Community 88
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
77 /100 Good
Architecture 85
Code Quality 88
Innovation 70
Learning Curve 65

http is a foundational Rust crate providing the shared Request, Response, Method, StatusCode, Uri, Version, and HeaderMap types that most of the Rust HTTP ecosystem — hyper, tonic, axum, reqwest, tower, and many others — builds on top of. Rather than each HTTP-adjacent crate defining its own incompatible request/response representations, they all depend on http so values can move between a client, a server, and any middleware in between without conversion glue.

The crate intentionally contains no networking, parsing, or I/O code of its own; it exists purely to standardize the vocabulary types that HTTP-related crates pass to each other, with an optimized HeaderMap implementation as its most substantial piece of internal logic.

What You Get

  • Request<T> and Response<T> generic types with ergonomic builder APIs for constructing HTTP messages
  • HeaderMap - a purpose-built multi-map optimized for HTTP header storage and case-insensitive lookup
  • Method, StatusCode, Uri, and Version types shared across the entire Rust HTTP ecosystem
  • Zero-copy-friendly HeaderName/HeaderValue types backed by bytes::Bytes
  • Conversion trait implementations (convert.rs) so common std types interoperate cleanly with the crate’s types

Common Use Cases

  • Defining the request/response types passed between a client and server built on hyper, tonic, or axum
  • Writing HTTP middleware (a tower::Layer) that needs to inspect or modify headers, method, or status without depending on any particular server implementation
  • Implementing a new HTTP client or server that wants to interoperate with the existing hyper-ecosystem tooling out of the box
  • Building an HTTP proxy or gateway that manipulates requests/responses using a common, well-tested type vocabulary

Under The Hood

Architecture Across roughly 14,500 lines, the crate is organized around independent, focused modules — request.rs and response.rs define the generic Request<T>/Response<T> builder types, header/ implements the HeaderMap/HeaderName/HeaderValue trio as its own self-contained sub-module, and method.rs, status.rs, version.rs, uri/ each own one small, well-scoped vocabulary type — reflecting the crate’s deliberate scope discipline of shipping types and nothing else. Tech Stack Depends on bytes for zero-copy byte storage in header values and little else, keeping the dependency graph shallow since this crate sits at the base of the dependency tree for a large share of the Rust HTTP ecosystem (hyper, axum, tonic, reqwest, tower). Code Quality tests/header_map.rs and tests/header_map_fuzz.rs reflect that HeaderMap — the crate’s most algorithmically complex piece, since it’s a custom hash-map variant tuned for HTTP header access patterns — receives targeted fuzz testing in addition to conventional unit tests, appropriate rigor for a type this deeply relied upon. API Design The builder pattern on Request/Response (Request::builder().method(...).uri(...).body(...)) is now the de facto idiom across the Rust HTTP ecosystem precisely because this crate established it first, and extensive From/TryFrom conversions in convert.rs mean callers rarely need explicit type-conversion boilerplate at API boundaries.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers