use of com.netflix.zuul.message.http.HttpQueryParams in project zuul by Netflix.
the class ProxyEndpoint method massageRequestURI.
private static HttpRequestMessage massageRequestURI(HttpRequestMessage request) {
final SessionContext context = request.getContext();
String modifiedPath;
HttpQueryParams modifiedQueryParams = null;
String uri = null;
if (context.get("requestURI") != null) {
uri = (String) context.get("requestURI");
}
// If another filter has specified an overrideURI, then use that instead of requested URI.
final Object override = context.get("overrideURI");
if (override != null) {
uri = override.toString();
}
if (null != uri) {
int index = uri.indexOf('?');
if (index != -1) {
// Strip the query string off of the URI.
String paramString = uri.substring(index + 1);
modifiedPath = uri.substring(0, index);
try {
paramString = URLDecoder.decode(paramString, "UTF-8");
modifiedQueryParams = new HttpQueryParams();
StringTokenizer stk = new StringTokenizer(paramString, "&");
while (stk.hasMoreTokens()) {
String token = stk.nextToken();
int idx = token.indexOf("=");
if (idx != -1) {
String key = token.substring(0, idx);
String val = token.substring(idx + 1);
modifiedQueryParams.add(key, val);
}
}
} catch (UnsupportedEncodingException e) {
LOG.error("Error decoding url query param - " + paramString, e);
}
} else {
modifiedPath = uri;
}
request.setPath(modifiedPath);
if (null != modifiedQueryParams) {
request.setQueryParams(modifiedQueryParams);
}
}
return request;
}
Aggregations