Skip to content

Commit 07e4ee1

Browse files
kariyLucioFranco
andauthored
fix (#1562)
Co-authored-by: Lucio Franco <[email protected]>
1 parent e8cb48f commit 07e4ee1

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

tonic/src/client/grpc.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::{
88
};
99
use http::{
1010
header::{HeaderValue, CONTENT_TYPE, TE},
11-
uri::{Parts, PathAndQuery, Uri},
11+
uri::{PathAndQuery, Uri},
1212
};
1313
use http_body::Body;
1414
use std::{fmt, future};
@@ -372,13 +372,20 @@ impl GrpcConfig {
372372
request: Request<BoxBody>,
373373
path: PathAndQuery,
374374
) -> http::Request<BoxBody> {
375-
let scheme = self.origin.scheme().cloned();
376-
let authority = self.origin.authority().cloned();
377-
378-
let mut parts = Parts::default();
379-
parts.path_and_query = Some(path);
380-
parts.scheme = scheme;
381-
parts.authority = authority;
375+
let mut parts = self.origin.clone().into_parts();
376+
377+
match &parts.path_and_query {
378+
Some(pnq) if pnq != "/" => {
379+
parts.path_and_query = Some(
380+
format!("{}{}", pnq.path(), path)
381+
.parse()
382+
.expect("must form valid path_and_query"),
383+
)
384+
}
385+
_ => {
386+
parts.path_and_query = Some(path);
387+
}
388+
}
382389

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

0 commit comments

Comments
 (0)