fix panic on bad http path prefix
This commit is contained in:
parent
07d38cae6c
commit
30cd4a72b9
2 changed files with 18 additions and 2 deletions
|
@ -156,7 +156,15 @@ pub async fn connect(
|
||||||
.header(CONTENT_TYPE, "application/json")
|
.header(CONTENT_TYPE, "application/json")
|
||||||
.version(hyper::Version::HTTP_2);
|
.version(hyper::Version::HTTP_2);
|
||||||
|
|
||||||
let headers = req.headers_mut().unwrap();
|
let headers = match req.headers_mut() {
|
||||||
|
Some(h) => h,
|
||||||
|
None => {
|
||||||
|
return Err(anyhow!(
|
||||||
|
"failed to build HTTP request to contact the server {:?}. Most likely path_prefix `{}` or http headers is not valid",
|
||||||
|
req, client.config.http_upgrade_path_prefix
|
||||||
|
))
|
||||||
|
}
|
||||||
|
};
|
||||||
for (k, v) in &client.config.http_headers {
|
for (k, v) in &client.config.http_headers {
|
||||||
let _ = headers.remove(k);
|
let _ = headers.remove(k);
|
||||||
headers.append(k, v.clone());
|
headers.append(k, v.clone());
|
||||||
|
|
|
@ -257,7 +257,15 @@ pub async fn connect(
|
||||||
)
|
)
|
||||||
.version(hyper::Version::HTTP_11);
|
.version(hyper::Version::HTTP_11);
|
||||||
|
|
||||||
let headers = req.headers_mut().unwrap();
|
let headers = match req.headers_mut() {
|
||||||
|
Some(h) => h,
|
||||||
|
None => {
|
||||||
|
return Err(anyhow!(
|
||||||
|
"failed to build HTTP request to contact the server {:?}. Most likely path_prefix `{}` or http headers is not valid",
|
||||||
|
req.body(Empty::<Bytes>::new()), client_cfg.http_upgrade_path_prefix
|
||||||
|
))
|
||||||
|
}
|
||||||
|
};
|
||||||
for (k, v) in &client_cfg.http_headers {
|
for (k, v) in &client_cfg.http_headers {
|
||||||
let _ = headers.remove(k);
|
let _ = headers.remove(k);
|
||||||
headers.append(k, v.clone());
|
headers.append(k, v.clone());
|
||||||
|
|
Loading…
Reference in a new issue