|
30 | 30 | //! use async_h1::client; |
31 | 31 | //! use async_std::net::{TcpStream}; |
32 | 32 | //! use http_types::{Error, Method, Request, Url}; |
33 | | -//! |
| 33 | +//! |
34 | 34 | //! #[async_std::main] |
35 | 35 | //! async fn main() -> Result<(), Error> { |
36 | 36 | //! let stream = TcpStream::connect("127.0.0.1:8080").await?; |
37 | 37 | //! let peer_addr = stream.peer_addr()?; |
38 | 38 | //! println!("connecting to {}", peer_addr); |
39 | | -//! |
| 39 | +//! |
40 | 40 | //! for i in 0usize..2 { |
41 | 41 | //! println!("making request {}/2", i + 1); |
42 | 42 | //! let url = Url::parse(&format!("http://{}/foo", peer_addr)).unwrap(); |
|
55 | 55 | //! use async_std::prelude::*; |
56 | 56 | //! use async_std::task; |
57 | 57 | //! use http_types::{Response, StatusCode}; |
58 | | -//! |
| 58 | +//! |
59 | 59 | //! #[async_std::main] |
60 | 60 | //! async fn main() -> http_types::Result<()> { |
61 | 61 | //! // Open up a TCP connection and create a URL. |
62 | 62 | //! let listener = TcpListener::bind(("127.0.0.1", 8080)).await?; |
63 | 63 | //! let addr = format!("http://{}", listener.local_addr()?); |
64 | 64 | //! println!("listening on {}", addr); |
65 | | -//! |
| 65 | +//! |
66 | 66 | //! // For each incoming TCP connection, spawn a task and call `accept`. |
67 | 67 | //! let mut incoming = listener.incoming(); |
68 | 68 | //! while let Some(stream) = incoming.next().await { |
|
76 | 76 | //! } |
77 | 77 | //! Ok(()) |
78 | 78 | //! } |
79 | | -//! |
| 79 | +//! |
80 | 80 | //! // Take a TCP stream, and convert it into sequential HTTP request / response pairs. |
81 | 81 | //! async fn accept(addr: String, stream: TcpStream) -> http_types::Result<()> { |
82 | 82 | //! println!("starting new connection from {}", stream.peer_addr()?); |
|
99 | 99 | /// The maximum amount of headers parsed on the server. |
100 | 100 | const MAX_HEADERS: usize = 128; |
101 | 101 |
|
102 | | -mod server; |
103 | 102 | mod chunked; |
104 | 103 | mod date; |
| 104 | +mod server; |
105 | 105 |
|
106 | 106 | #[doc(hidden)] |
107 | 107 | pub mod client; |
|
0 commit comments