Fix host header
This commit is contained in:
parent
102d50a024
commit
1f924d65fb
@ -333,9 +333,8 @@ fn create_proxied_request<B>(
|
||||
|
||||
debug!("Setting headers of proxied request");
|
||||
|
||||
request
|
||||
.headers_mut()
|
||||
.insert(HOST, HeaderValue::from_str(uri.host().unwrap())?);
|
||||
// remove the original HOST header. It will be set by the client that sends the request
|
||||
request.headers_mut().remove(HOST);
|
||||
|
||||
*request.uri_mut() = uri;
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
use hyper::client::connect::dns::GaiResolver;
|
||||
use hyper::client::HttpConnector;
|
||||
use hyper::header::{CONNECTION, UPGRADE};
|
||||
use hyper::header::{CONNECTION, HOST, UPGRADE};
|
||||
use hyper::server::conn::AddrStream;
|
||||
use hyper::service::{make_service_fn, service_fn};
|
||||
use hyper::{Body, Client, Request, Response, Server, StatusCode, Uri};
|
||||
use hyper::{Body, Client, HeaderMap, Request, Response, Server, StatusCode, Uri};
|
||||
use hyper_reverse_proxy::ReverseProxy;
|
||||
use std::convert::Infallible;
|
||||
use std::net::{IpAddr, SocketAddr};
|
||||
@ -85,9 +85,15 @@ async fn test_upgrade_unrequested(ctx: &mut ProxyTestContext) {
|
||||
#[test_context(ProxyTestContext)]
|
||||
#[tokio::test]
|
||||
async fn test_get(ctx: &mut ProxyTestContext) {
|
||||
let mut headers = HeaderMap::new();
|
||||
headers.insert(
|
||||
HOST,
|
||||
format!("127.0.0.1:{}", ctx.http_back.port).parse().unwrap(),
|
||||
);
|
||||
ctx.http_back.add(
|
||||
HandlerBuilder::new("/foo")
|
||||
.status_code(StatusCode::OK)
|
||||
.headers(headers)
|
||||
.build(),
|
||||
);
|
||||
let resp = Client::new().get(ctx.uri("/foo")).await.unwrap();
|
||||
|
Loading…
Reference in New Issue
Block a user