You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The client sends an HTTP1.1 request to the hyper server, and the state.version of the hyper server is HTTP1.1. The hyper server sends the request to the hyper client, and the state.version of the hyper client is HTTP1.1. Finally, the hyper client sends the request to the server. If the HTTP protocol of the response returned by the server is HTTP1.0 and the response is in the keepalive state, the state.version of the hyper client is HTTP1.0. If HTTP1.1 requests are received later, the HyperClient sends the requests to the server using HTTP1.0.
Related Code:
// If we know the remote speaks an older version, we try to fix up any messages// to work with our older peer.fnenforce_version(&mutself,head:&mutMessageHead<T::Outgoing>){ifletVersion::HTTP_10 = self.state.version{// Fixes response or connection when keep-alive header is not presentself.fix_keep_alive(head);// If the remote only knows HTTP/1.0, we should force ourselves// to do only speak HTTP/1.0 as well.
head.version = Version::HTTP_10;}// If the remote speaks HTTP/1.1, then it *should* be fine with// both HTTP/1.0 and HTTP/1.1 from us. So again, we just let// the user's headers be.}
use std::net::SocketAddr;use hyper::{Body,Response};use hyper::server::conn::AddrStream;pubasyncfnproxy(listen:SocketAddr,c_addr:SocketAddr){use hyper::Error;use hyper::service::{make_service_fn, service_fn};// And a MakeService to handle each connection...let client = hyper::client::Client::new();let make_svc = make_service_fn(|io:&AddrStream| {println!("new conn: {:?}", io.remote_addr());let client = client.clone();asyncmove{let client = client.clone();Ok::<_,Error>(service_fn(move |mut req| {let client = client.clone();asyncmove{println!("request: {:?}", req);let url = format!("http://{}{}", c_addr, req.uri().path());*req.uri_mut() = url.parse().unwrap();let result = client.request(req).await;println!("response: {:?}", result);println!();
result
}}))}});
hyper::server::Server::bind(&listen).serve(make_svc).await.unwrap();}pubasyncfnsimple_listener(listen:SocketAddr){use hyper::Error;use hyper::service::{make_service_fn, service_fn};// And a MakeService to handle each connection...let make_svc = make_service_fn(|_| {asyncmove{Ok::<_,Error>(service_fn(move | req| {asyncmove{println!("{:?}",req);Ok::<_,Error>(Response::new(Body::from("hello")))}}))}});
hyper::server::Server::bind(&listen).serve(make_svc).await.unwrap();}
When the client microservice sends HTTP1.0 and HTTP1.1 requests in turn, the Hyper Server sends the requests to the Hyper Client. The HTTP protocol of the Hyper Client is gradually set to HTTP1.0. As a result, the HTTP protocol of subsequent requests is changed to HTTP1.0
That doesn't seem to be the outcome we want.
The text was updated successfully, but these errors were encountered:
Version
hyper 0.14.18
Platform
eulerosv2r7.x86_64
Description
The client sends an HTTP1.1 request to the hyper server, and the state.version of the hyper server is HTTP1.1. The hyper server sends the request to the hyper client, and the state.version of the hyper client is HTTP1.1. Finally, the hyper client sends the request to the server. If the HTTP protocol of the response returned by the server is HTTP1.0 and the response is in the keepalive state, the state.version of the hyper client is HTTP1.0. If HTTP1.1 requests are received later, the HyperClient sends the requests to the server using HTTP1.0.
Related Code:
demo:
demo code:
client microservice
hyper server
hyper client
server microservice
lib
When the client microservice sends HTTP1.0 and HTTP1.1 requests in turn, the Hyper Server sends the requests to the Hyper Client. The HTTP protocol of the Hyper Client is gradually set to HTTP1.0. As a result, the HTTP protocol of subsequent requests is changed to HTTP1.0
That doesn't seem to be the outcome we want.
The text was updated successfully, but these errors were encountered: