edicl/drakma — pull request #30 by ruricolist (2013-07-03 02:13:16+00:00)
Title: Change handling of empty and missing Location headers

Drakma at the moment handles both missing and empty Location headers the same way, by redirecting to the host. This is wrong for empty Location headers, and inconvenient for missing ones.

For context, there are extended discussions of how different browsers handle the problem in these Mozilla bugs:

https://bugzilla.mozilla.org/show_bug.cgi?id=742508
https://bugzilla.mozilla.org/show_bug.cgi?id=742174

In short, there’s nothing invalid about a blank location header; it’s equivalent to a redirect to the same URI.

As for a missing Location header, I think the best thing is to return the body, on the general principle that it’s best to handle errors in the way that destroys the least information.

This is a real problem, not a quibble. At TBRSS I’m running into what I think are botched attempts at Feedburner redirects. They return 302, but with no Location header, and so, instead of the feed, Drakma returns the blog itself.