I have an application that uses Javascript code to generate URLs that are sent to a REST endpoint running under Apache Tomcat 8.5. The data sent to the URL includes an identifier field that may contain "special" characters. I encode this identifier using the Javascript function encodeURIComponent
.
However, with some of the identifier strings, the connection is being instantly terminated after the URL is sent (without even waiting for the request to be fully sent), with the error 400 Bad Request
and an empty response entity.
An example URL that causes the failure is:
http://localhost:3000/admin_api/getTranscript/%2B~%2B)%2Fe*3%3Ep%2596%5B(%2Fv%3C03
This doesn't appear to be related to this similar question because the characters causing issue in that particular case are |
, {
and }
, none of which are present in my URL.
Why is Tomcat rejecting this URL, and what can I do to prevent this issue? I'd prefer a change on the server side rather than client, because I have already-deployed clients that would need updating.