Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi all,
This PR cleans up the request query to allow an HttpClient to process query strings that come in with invalid characters ({, }, |, ^, etc) without failing on a
org.apache.http.client.ClientProtocolException
.Before this code change, if you try to hit
localhost:8080/?a={}
, you will receive a blank page caused by the above exception. This is poor behavior, as most web servers are able to handle these invalid characters without rendering an error. To fix this, we re-encode the query string so that it will have the proper characters according to https://tools.ietf.org/html/rfc3986#page-12 (Sections 2.1-2.3).You will notice that I use
URLDecoder
to decode the query string, but then useURI
(and notURLEncoder
) to re-encode it. This is done to follow best practices outlined on StackOverflow [1] [2].Questions, comments, concerns?