Infinite redirects to wikipedia.com

288 views
Skip to first unread message

Scott Smith

unread,
Aug 5, 2016, 1:42:42 PM8/5/16
to spray.io User List
Hi
When a wikipedia.com URL has a unencoded single quote or ampersand in the URL path, it sends a redirect with a Location header with the encoded character. For example:


Produces this:

HTTP/1.1 301 Moved Permanently
Date: Fri, 05 Aug 2016 17:33:36 GMT
Content-Type: text/html; charset=utf-8

Spray's Uri object always decodes these two characters (so it sees the Location header as "https://en.wikipedia.org/wiki/A_Knight's_Tale"), so the request gets stuck in an infinite loop through the redirect.

I can get around the problem by adding a Raw-Request-URI to my requests. However, I'm never able to recognise a Location header which requires the encoded character because the parsing of responses uses the Uri object in the Location header. In my code, I can add a special case for wikipedia.com requests, but I'd really like to be able to make it more general and handle any other servers which may also do the same.

Is there anyway to get access to the raw value of the Location header without it being passed into a Uri object?
thx
scott s

Алексей Перфильев

unread,
Aug 22, 2016, 3:26:39 AM8/22/16
to spray.io User List

I have similar problem, if Location is not absolute path, like Location: authStep?cid=4aa827df&nocache=-1729779621 it also cause infinite redirect

Alex Perfilev


пятница, 5 августа 2016 г., 20:42:42 UTC+3 пользователь Scott Smith написал:
Reply all
Reply to author
Forward
0 new messages