From aa7ff605da3b706e855f9633b8dddeb9463217d4 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Fri, 21 Jun 2024 12:15:00 -0400 Subject: [PATCH] docs(client): replace example on mod page with link to guide --- src/client/conn/mod.rs | 50 ++++-------------------------------------- 1 file changed, 4 insertions(+), 46 deletions(-) diff --git a/src/client/conn/mod.rs b/src/client/conn/mod.rs index 9e68aa6d00..316aac9d48 100644 --- a/src/client/conn/mod.rs +++ b/src/client/conn/mod.rs @@ -5,56 +5,14 @@ //! are not handled at this level. This module provides the building blocks to //! customize those things externally. //! -//! If you are looking for a convenient HTTP client, -//! then you may wish to consider [reqwest](https://github.com/seanmonstar/reqwest) -//! for a high level client or [`hyper-util`'s client](https://docs.rs/hyper-util/latest/hyper_util/client/index.html) +//! If you are looking for a convenient HTTP client, then you may wish to +//! consider [reqwest](https://github.com/seanmonstar/reqwest) for a high level +//! client or [`hyper-util`'s client](https://docs.rs/hyper-util/latest/hyper_util/client/index.html) //! if you want to keep it more low level / basic. //! //! ## Example //! -//! A simple example that uses the `SendRequest` struct to talk HTTP over some TCP stream. -//! -//! ```no_run -//! # #[cfg(all(feature = "client", feature = "http1"))] -//! # mod rt { -//! use bytes::Bytes; -//! use http::{Request, StatusCode}; -//! use http_body_util::Empty; -//! use hyper::client::conn; -//! # use hyper::rt::{Read, Write}; -//! # async fn run(tcp: I) -> Result<(), Box> -//! # where -//! # I: Read + Write + Unpin + Send + 'static, -//! # { -//! let (mut request_sender, connection) = conn::http1::handshake(tcp).await?; -//! -//! // spawn a task to poll the connection and drive the HTTP state -//! tokio::spawn(async move { -//! if let Err(e) = connection.await { -//! eprintln!("Error in connection: {}", e); -//! } -//! }); -//! -//! let request = Request::builder() -//! // We need to manually add the host header because SendRequest does not -//! .header("Host", "example.com") -//! .method("GET") -//! .body(Empty::::new())?; -//! -//! let response = request_sender.send_request(request).await?; -//! assert!(response.status() == StatusCode::OK); -//! -//! let request = Request::builder() -//! .header("Host", "example.com") -//! .method("GET") -//! .body(Empty::::new())?; -//! -//! let response = request_sender.send_request(request).await?; -//! assert!(response.status() == StatusCode::OK); -//! # Ok(()) -//! # } -//! # } -//! ``` +//! See the [client guide](https://hyper.rs/guides/1/client/basic/). #[cfg(feature = "http1")] pub mod http1;