blob: 2ae8d56cd3a5d9e6b09010628e736599268992a8 [file] [log] [blame] [view]
James Farrellbe12d662024-10-08 21:25:23 +00001# HTTP
2
3A general purpose library of common HTTP types
4
5[![CI](https://github.com/hyperium/http/workflows/CI/badge.svg)](https://github.com/hyperium/http/actions?query=workflow%3ACI)
6[![Crates.io](https://img.shields.io/crates/v/http.svg)](https://crates.io/crates/http)
7[![Documentation](https://docs.rs/http/badge.svg)][dox]
8
9More information about this crate can be found in the [crate
10documentation][dox].
11
12[dox]: https://docs.rs/http
13
14## Usage
15
16To use `http`, first add this to your `Cargo.toml`:
17
18```toml
19[dependencies]
20http = "0.2"
21```
22
23Next, add this to your crate:
24
25```rust
26use http::{Request, Response};
27
28fn main() {
29 // ...
30}
31```
32
33## Examples
34
35Create an HTTP request:
36
37```rust
38use http::Request;
39
40fn main() {
41 let request = Request::builder()
42 .uri("https://www.rust-lang.org/")
43 .header("User-Agent", "awesome/1.0")
44 .body(())
45 .unwrap();
46}
47```
48
49Create an HTTP response:
50
51```rust
52use http::{Response, StatusCode};
53
54fn main() {
55 let response = Response::builder()
56 .status(StatusCode::MOVED_PERMANENTLY)
57 .header("Location", "https://www.rust-lang.org/install.html")
58 .body(())
59 .unwrap();
60}
61```
62
63# Supported Rust Versions
64
65This project follows the [Tokio MSRV][msrv] and is currently set to `1.49`.
66
67[msrv]: https://github.com/tokio-rs/tokio/#supported-rust-versions
68
69# License
70
71Licensed under either of
72
73- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or https://apache.org/licenses/LICENSE-2.0)
74- MIT license ([LICENSE-MIT](LICENSE-MIT) or https://opensource.org/licenses/MIT)
75
76# Contribution
77
78Unless you explicitly state otherwise, any contribution intentionally submitted
79for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
80dual licensed as above, without any additional terms or conditions.