From ea5b49b7d4e18c1eaa7f42db0ff91d1dcca56a04 Mon Sep 17 00:00:00 2001 From: ZenTeaCC <36598604+Muffeter@users.noreply.github.com> Date: Mon, 7 Apr 2025 20:17:10 +0800 Subject: [PATCH] docs(examples): alias Builder for clarity in http_proxy (#3873) --- examples/http_proxy.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/http_proxy.rs b/examples/http_proxy.rs index acdd3127..58712b0f 100644 --- a/examples/http_proxy.rs +++ b/examples/http_proxy.rs @@ -4,8 +4,6 @@ use std::net::SocketAddr; use bytes::Bytes; use http_body_util::{combinators::BoxBody, BodyExt, Empty, Full}; -use hyper::client::conn::http1::Builder; -use hyper::server::conn::http1; use hyper::service::service_fn; use hyper::upgrade::Upgraded; use hyper::{Method, Request, Response}; @@ -16,6 +14,9 @@ use tokio::net::{TcpListener, TcpStream}; mod support; use support::TokioIo; +type ClientBuilder = hyper::client::conn::http1::Builder; +type ServerBuilder = hyper::server::conn::http1::Builder; + // To try this example: // 1. cargo run --example http_proxy // 2. config http_proxy in command line @@ -35,7 +36,7 @@ async fn main() -> Result<(), Box> { let io = TokioIo::new(stream); tokio::task::spawn(async move { - if let Err(err) = http1::Builder::new() + if let Err(err) = ServerBuilder::new() .preserve_header_case(true) .title_case_headers(true) .serve_connection(io, service_fn(proxy)) @@ -94,7 +95,7 @@ async fn proxy( let stream = TcpStream::connect((host, port)).await.unwrap(); let io = TokioIo::new(stream); - let (mut sender, conn) = Builder::new() + let (mut sender, conn) = ClientBuilder::new() .preserve_header_case(true) .title_case_headers(true) .handshake(io)