I recently came across a server that’s sending a Location header (for a redirect) that looks like this:
Location: http://www.example.com/something.ext?auth=123|123
When I try to use this in my Java program it complains about an “Illegal character in query” and fails.
So is the server doing something incorrect? Is this legal?
Use escapes:
|is escaped with%7C, so your URL becomes:Locationheader as per HTTP/1.1 is defined as:Per HTTP/1.1:
RFC 2396 is obsoleted by RFC 3986, which requires escaping of some characters (see the RFC for the definitive information). It’s the responsibility of the source to provide the correct URL, so yes – you are responsible to provide a correctly escaped URL in this case.