Issue #1568 - fixing accidental NPE with no query

This commit is contained in:
Joakim Erdfelt 2017-05-23 11:59:39 -07:00
parent 296050dfc4
commit 4731470188
1 changed files with 13 additions and 10 deletions

View File

@ -66,17 +66,20 @@ public class ServletUpgradeRequest implements UpgradeRequest
String authority = servletURI.getAuthority();
String path = servletURI.getPath();
this.queryString = httpRequest.getQueryString();
String decodedQuery = null;
if (this.queryString != null)
{
try
{
decodedQuery = URLDecoder.decode(queryString, StandardCharsets.UTF_8.toString());
}
catch (UnsupportedEncodingException e)
{
decodedQuery = queryString;
}
}
String fragment = null;
URI reqURI;
try
{
reqURI = new URI(scheme,authority,path, URLDecoder.decode(queryString, StandardCharsets.UTF_8.toString()),fragment);
}
catch (UnsupportedEncodingException e)
{
reqURI = new URI(scheme,authority,path, queryString, fragment);
}
this.requestURI = reqURI;
this.requestURI = new URI(scheme,authority,path, decodedQuery, fragment);
this.request = new UpgradeHttpServletRequest(httpRequest);
}