This repository was archived by the owner on Feb 22, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
main/java/eu/fusepool/p3/proxy
test/java/eu/fusepool/p3/proxy Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ public class ProxyHandler extends AbstractHandler {
8989 public void handle (String target , Request baseRequest ,
9090 final HttpServletRequest inRequest , final HttpServletResponse outResponse )
9191 throws IOException , ServletException {
92- final String targetUriString = targetBaseUri + inRequest . getRequestURI ( );
92+ final String targetUriString = targetBaseUri + getFullRequestUriPath ( inRequest );
9393 final String requestUri = getFullRequestUrl (inRequest );
9494 //System.out.println(targetUriString);
9595 final URI targetUri ;
@@ -195,6 +195,14 @@ private static String getFullRequestUrl(HttpServletRequest request) {
195195 }
196196 return requestURL .toString ();
197197 }
198+
199+ private static String getFullRequestUriPath (HttpServletRequest request ) {
200+ final StringBuffer requestURL = new StringBuffer (request .getRequestURI ());
201+ if (request .getQueryString () != null ) {
202+ requestURL .append ("?" ).append (request .getQueryString ());
203+ }
204+ return requestURL .toString ();
205+ }
198206
199207 /**
200208 * If uri is a transforming container returns the URI of the associated
Original file line number Diff line number Diff line change @@ -105,6 +105,26 @@ public void nonTransformingContainer() throws Exception {
105105
106106 }
107107
108+ @ Test
109+ public void queryParamsForwarded () throws Exception {
110+
111+ final String textResponse = "hello" ;
112+
113+ stubFor (get (urlEqualTo ("/my/test?a=1&b=2" ))
114+ .withHeader ("Accept" , equalTo ("text/plain" ))
115+ .willReturn (aResponse ()
116+ .withStatus (200 )
117+ .withHeader ("Content-Type" , "text/plain" )
118+ .withBody (textResponse )));
119+
120+ RestAssured .given ().header ("Accept" , "text/plain" )
121+ .expect ().statusCode (HttpStatus .SC_OK )
122+ .header ("Content-Type" , "text/plain" )
123+ .body (new IsEqual (textResponse )).when ()
124+ .get ("/my/test?a=1&b=2" );
125+
126+ }
127+
108128 @ Test
109129 public void transformingContainer () throws Exception {
110130
You can’t perform that action at this time.
0 commit comments