Fix potential decoding and reencoding issues in query params when using SimpleHostRoutingFilter (#1464)

Some webserver are picky with the encoding (uWSGI for example) and the current code behavior of decoding and reencoding the query string can lead to valid requests
rejected by the backend after the modifications in Zuul. This commit adds an optional parameter to force the original encoding of the query string in SimpleHostRoutingFilter.

Fixes gh-971
This commit is contained in:
Jacques-Etienne Beaudet
2017-01-09 10:53:16 -05:00
committed by Spencer Gibb
parent 4eac8a5a47
commit bd6d732fc7
5 changed files with 224 additions and 14 deletions

View File

@@ -1638,6 +1638,26 @@ $ curl -v -H "Transfer-Encoding: chunked" \
-F "file=@mylarge.iso" localhost:9999/zuul/simple/file
----
=== Query String Encoding
When processing the incoming request, query params are decoded so they can be available for possible modifications in
Zuul filters. They are then re-encoded when building the backend request in the route filters. The result
can be different than the original input if it was encoded using Javascript's `encodeURIComponent()` method for example.
While this causes no issues in most cases, some web servers can be picky with the encoding of complex query string.
To force the original encoding of the query string, it is possible to pass a special flag to `ZuulProperties` so
that the query string is taken as is with the `HttpServletRequest::getQueryString` method :
.application.yml
[source,yaml]
----
zuul:
forceOriginalQueryStringEncoding: true
----
*Note:* This special flag only works with `SimpleHostRoutingFilter` and you loose the ability to easily override
query parameters with `RequestContext.getCurrentContext().setRequestQueryParams(someOverriddenParameters)` since
the query string is now fetched directly on the original `HttpServletRequest`.
=== Plain Embedded Zuul
You can also run a Zuul server without the proxying, or switch on parts of the proxying platform selectively, if you