1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//! # giong-http
//!
//! A small, strict HTTP/1.1 server for the [giong] thread-per-core
//! runtime.
//!
//! ```no_run
//! use giong::net::TcpListener;
//! use giong_http::{Request, Response, Server};
//!
//! async fn handler(req: Request) -> Response {
//! match (req.method(), req.path()) {
//! ("GET", "/health") => Response::text("ok"),
//! ("POST", "/echo") => Response::new(200).body(req.body().to_vec()),
//! _ => Response::new(404),
//! }
//! }
//!
//! fn main() -> std::io::Result<()> {
//! giong::Builder::new()
//! .shutdown_on_signals(true)
//! .shutdown_grace(std::time::Duration::from_secs(10))
//! .build()?
//! .run(|_worker| async {
//! // One listener per worker; the kernel spreads connections.
//! let listener = TcpListener::bind("0.0.0.0:8080").expect("bind");
//! Server::new().serve(listener, handler).await;
//! })
//! }
//! ```
//!
//! ## What it does
//!
//! * HTTP/1.1 and HTTP/1.0, keep-alive, pipelining (responses to pipelined
//! requests are sent in one write).
//! * Request bodies with `Content-Length` or chunked encoding, fully received
//! before the handler runs; `Expect: 100-continue`.
//! * Limits on head and body size, timeouts for idle connections, slow
//! requests and slow readers.
//! * Graceful shutdown: requests in progress are answered, idle connections
//! close.
//! * Strict parsing. Requests that a proxy in front might read differently
//! (two lengths, a length plus chunked encoding, whitespace before a colon,
//! bare line feeds, folded headers) are rejected with `400`.
//!
//! ## What it does not do (yet)
//!
//! HTTP/2, streaming bodies, compression, routing.
//!
//! ## HTTPS
//!
//! With the `tls` feature, [`Server::serve_tls`] serves the same handlers over
//! TLS, using the `giong-tls` crate (rustls).
pub use Request;
pub use ;
pub use ;