|
27 | 27 | //! __HTTP client__
|
28 | 28 | //!
|
29 | 29 | //! ```no_run
|
30 |
| -//! use async_h1::client; |
31 |
| -//! use async_std::net::{TcpStream}; |
32 |
| -//! use http_types::{Error, Method, Request, Url}; |
| 30 | +//! use async_std::net::TcpStream; |
| 31 | +//! use http_types::{Method, Request, Url}; |
33 | 32 | //!
|
34 | 33 | //! #[async_std::main]
|
35 |
| -//! async fn main() -> Result<(), Error> { |
| 34 | +//! async fn main() -> http_types::Result<()> { |
36 | 35 | //! let stream = TcpStream::connect("127.0.0.1:8080").await?;
|
| 36 | +//! |
37 | 37 | //! let peer_addr = stream.peer_addr()?;
|
38 | 38 | //! println!("connecting to {}", peer_addr);
|
| 39 | +//! let url = Url::parse(&format!("http://{}/foo", peer_addr))?; |
| 40 | +//! |
| 41 | +//! let req = Request::new(Method::Get, url); |
| 42 | +//! let res = async_h1::connect(stream.clone(), req).await?; |
| 43 | +//! println!("{:?}", res); |
39 | 44 | //!
|
40 |
| -//! for i in 0usize..2 { |
41 |
| -//! println!("making request {}/2", i + 1); |
42 |
| -//! let url = Url::parse(&format!("http://{}/foo", peer_addr)).unwrap(); |
43 |
| -//! let req = Request::new(Method::Get, url); |
44 |
| -//! let res = client::connect(stream.clone(), req).await?; |
45 |
| -//! println!("{:?}", res); |
46 |
| -//! } |
47 | 45 | //! Ok(())
|
48 | 46 | //! }
|
49 | 47 | //! ```
|
|
0 commit comments