From 07e4ee1745397e3df61025a69650f0ab48c9551d Mon Sep 17 00:00:00 2001 From: Ammar Arif Date: Thu, 16 Nov 2023 00:18:14 +0300 Subject: [PATCH] fix (#1562) Co-authored-by: Lucio Franco --- tonic/src/client/grpc.rs | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/tonic/src/client/grpc.rs b/tonic/src/client/grpc.rs index 09ef3e934..e070f08d3 100644 --- a/tonic/src/client/grpc.rs +++ b/tonic/src/client/grpc.rs @@ -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}; @@ -372,13 +372,20 @@ impl GrpcConfig { request: Request, path: PathAndQuery, ) -> http::Request { - 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");