Skip to content

Commit

Permalink
fix (#1562)
Browse files Browse the repository at this point in the history
Co-authored-by: Lucio Franco <[email protected]>
  • Loading branch information
kariy and LucioFranco authored Nov 15, 2023
1 parent e8cb48f commit 07e4ee1
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions tonic/src/client/grpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{
};
use http::{
header::{HeaderValue, CONTENT_TYPE, TE},
uri::{Parts, PathAndQuery, Uri},
uri::{PathAndQuery, Uri},
};
use http_body::Body;
use std::{fmt, future};
Expand Down Expand Up @@ -372,13 +372,20 @@ impl GrpcConfig {
request: Request<BoxBody>,
path: PathAndQuery,
) -> http::Request<BoxBody> {
let scheme = self.origin.scheme().cloned();
let authority = self.origin.authority().cloned();

let mut parts = Parts::default();
parts.path_and_query = Some(path);
parts.scheme = scheme;
parts.authority = authority;
let mut parts = self.origin.clone().into_parts();

match &parts.path_and_query {
Some(pnq) if pnq != "/" => {
parts.path_and_query = Some(
format!("{}{}", pnq.path(), path)
.parse()
.expect("must form valid path_and_query"),
)
}
_ => {
parts.path_and_query = Some(path);
}
}

let uri = Uri::from_parts(parts).expect("path_and_query only is valid Uri");

Expand Down

0 comments on commit 07e4ee1

Please sign in to comment.