Skip to content

Commit

Permalink
fix: preserve the URI query in ProxyGetRequest::call (#1512)
Browse files Browse the repository at this point in the history
* 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 <niklasadolfsson1@gmail.com>
  • Loading branch information
dcfreire and niklasad1 authored Jan 8, 2025
1 parent cf55ed4 commit 0ab5b09
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions server/src/middleware/http/proxy_get_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ use jsonrpsee_types::{Id, RequestSer};
use std::collections::HashMap;
use std::future::Future;
use std::pin::Pin;
use std::str::FromStr;
use std::sync::Arc;
use std::task::{Context, Poll};
use tower::{Layer, Service};
Expand Down Expand Up @@ -149,8 +150,12 @@ where
(Some(method), &Method::GET) => {
// RPC methods are accessed with `POST`.
*req.method_mut() = Method::POST;
// Precautionary remove the URI.
*req.uri_mut() = Uri::from_static("/");
// Precautionary remove the URI path.
*req.uri_mut() = if let Some(query) = req.uri().query() {
Uri::from_str(&format!("/?{}", query)).expect("The query comes from a valid URI; qed")
} else {
Uri::from_static("/")
};
// Requests must have the following headers:
req.headers_mut().insert(CONTENT_TYPE, HeaderValue::from_static("application/json"));
req.headers_mut().insert(ACCEPT, HeaderValue::from_static("application/json"));
Expand Down

0 comments on commit 0ab5b09

Please sign in to comment.