cleartext backend request will be http1.1
This commit is contained in:
parent
c5c7847b92
commit
e76ac95062
5 changed files with 16 additions and 13 deletions
|
|
@ -4,6 +4,7 @@ use crate::{backend::UpstreamGroup, error::*, globals::Globals, log::*, utils::S
|
|||
use hyper::{
|
||||
client::connect::Connect,
|
||||
header::{self, HeaderValue},
|
||||
http::uri::Scheme,
|
||||
Body, Client, Request, Response, StatusCode, Uri, Version,
|
||||
};
|
||||
use std::{env, net::SocketAddr, sync::Arc};
|
||||
|
|
@ -289,10 +290,12 @@ where
|
|||
.insert(header::CONNECTION, HeaderValue::from_str("upgrade")?);
|
||||
}
|
||||
|
||||
// If not specified (force_httpXX_upstream) and https, version is preserved except for http/3
|
||||
apply_upstream_options_to_request_line(req, upstream_group)?;
|
||||
|
||||
// if not specified (force_httpXX_upstream), version is preserved except for http/3
|
||||
if req.version() == Version::HTTP_3 {
|
||||
// Maybe workaround: Change version to http/1.1 when destination scheme is http
|
||||
if req.version() != Version::HTTP_11 && upstream_chosen.uri.scheme() == Some(&Scheme::HTTP) {
|
||||
*req.version_mut() = Version::HTTP_11;
|
||||
} else if req.version() == Version::HTTP_3 {
|
||||
debug!("HTTP/3 is currently unsupported for request to upstream. Use HTTP/2.");
|
||||
*req.version_mut() = Version::HTTP_2;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ use hyper::{header, Request};
|
|||
pub(super) fn apply_upstream_options_to_request_line<B>(req: &mut Request<B>, upstream: &UpstreamGroup) -> Result<()> {
|
||||
for opt in upstream.opts.iter() {
|
||||
match opt {
|
||||
UpstreamOption::ConvertToHttp11 => *req.version_mut() = hyper::Version::HTTP_11,
|
||||
UpstreamOption::ConvertToHttp2 => *req.version_mut() = hyper::Version::HTTP_2,
|
||||
UpstreamOption::ConvertHttpsTo11 => *req.version_mut() = hyper::Version::HTTP_11,
|
||||
UpstreamOption::ConvertHttpsTo2 => *req.version_mut() = hyper::Version::HTTP_2,
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue