Skip to content

Commit 0ab5b09

Browse files
dcfreireniklasad1
andauthored
fix: preserve the URI query in ProxyGetRequest::call (#1512)
* fix: keep the URI query after stripping it * Update proxy_get_request.rs * Update server/src/middleware/http/proxy_get_request.rs --------- Co-authored-by: Niklas Adolfsson <[email protected]>
1 parent cf55ed4 commit 0ab5b09

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

server/src/middleware/http/proxy_get_request.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ use jsonrpsee_types::{Id, RequestSer};
4040
use std::collections::HashMap;
4141
use std::future::Future;
4242
use std::pin::Pin;
43+
use std::str::FromStr;
4344
use std::sync::Arc;
4445
use std::task::{Context, Poll};
4546
use tower::{Layer, Service};
@@ -149,8 +150,12 @@ where
149150
(Some(method), &Method::GET) => {
150151
// RPC methods are accessed with `POST`.
151152
*req.method_mut() = Method::POST;
152-
// Precautionary remove the URI.
153-
*req.uri_mut() = Uri::from_static("/");
153+
// Precautionary remove the URI path.
154+
*req.uri_mut() = if let Some(query) = req.uri().query() {
155+
Uri::from_str(&format!("/?{}", query)).expect("The query comes from a valid URI; qed")
156+
} else {
157+
Uri::from_static("/")
158+
};
154159
// Requests must have the following headers:
155160
req.headers_mut().insert(CONTENT_TYPE, HeaderValue::from_static("application/json"));
156161
req.headers_mut().insert(ACCEPT, HeaderValue::from_static("application/json"));

0 commit comments

Comments
 (0)