Skip to content

Commit

Permalink
adding getSanitizedQueryString()
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Roberts committed Sep 18, 2015
1 parent 9224295 commit bea994c
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -220,17 +220,17 @@ class SimpleHostRoutingFilter extends ZuulFilter {

switch (verb) {
case 'POST':
httpRequest = new HttpPost(uri + getQueryString())
httpRequest = new HttpPost(uri + getSanitizedQueryString())
InputStreamEntity entity = new InputStreamEntity(requestEntity, request.getContentLength())
httpRequest.setEntity(entity)
break
case 'PUT':
httpRequest = new HttpPut(uri + getQueryString())
httpRequest = new HttpPut(uri + getSanitizedQueryString())
InputStreamEntity entity = new InputStreamEntity(requestEntity, request.getContentLength())
httpRequest.setEntity(entity)
break;
default:
httpRequest = new BasicHttpRequest(verb, uri + getQueryString())
httpRequest = new BasicHttpRequest(verb, uri + getSanitizedQueryString())
}

try {
Expand All @@ -250,6 +250,17 @@ class SimpleHostRoutingFilter extends ZuulFilter {
return httpclient.execute(httpHost, httpRequest);
}

String getSanitizedQueryString() {
String encoding = "UTF-8"
String currentQueryString = getQueryString()
if (currentQueryString.equals("")) {
return ""
}

String decodedQueryString = URLDecoder.decode(currentQueryString, encoding)
return new URI(null, null, null, decodedQueryString, null).toString()
}

String getQueryString() {
HttpServletRequest request = RequestContext.currentContext.getRequest();
String query = request.getQueryString()
Expand Down

0 comments on commit bea994c

Please sign in to comment.