* * * * *

    Query Redirects in HTTP, or rather, the lack of documentation thereof

Over the past few days, Mark [1] and I have been going back and forth about
implementation details in Seminole [2]. It started out with a question about
encoding URL (Uniform Resource Locator)s—when do you convert a space to %20
and when do you covert it to + (answer: you can always use %20 but you can
only convert a space to a + in the query portion of a URL) but eventually got
around to a point not covered in RFC-2616 (Hypertext Transfer Protocol-
HTTP/1.1) [3].

> I like your idea of storing the query separate in the HttpdRequest object.
> It's a good idea, and I think may fix a problem where we do redirects and
> forget to tack on the query string. For example:
>
> Redirecting http://server/some/directory?stuff
>  -to-
>  http://server/some/directory/index.html?stuff
>
> Probably doesn't work now.
>

“Email from Mark”

Only thing is, RFC-2616 doesn't cover this situation. Sure, it covers what to
do when redirecting a POST (and even goes into mind-numbing detail about when
and when not to convert a POST to a GET when redirecting, and how that
interacts with proxy and caching servers) but not what to do when redirecting
a GET with a query.

I did some tests with Apache [4], and from what I can see, if Apache
generates the redirect (for example, http://www.example.net/path to
http://www.example.net/path**/**) it passes along the query string
(http://www.example.net/path?a=1&b=2 is redirected to
http://www.example.net/path**/**?a=1&b=2) but if the redirect comes from the
Redirect directive (for example, http://www.example.net/p.cgi to
http://server.example.org/q.cgi), then the query portion of the URL is
dropped entirely (http://www.example.net/p.cgi?a=1&b=2 is redirected to
http://server.example.org/q.cgi—note the missing query string) and since the
RFC (Request For Comments) is quite mum on what the correct behavior is,
we're having to wing it for now.

[1] http://www.conman.org/people/myg/
[2] http://gladesoft.com/products/seminole/
[3] http://www.cis.ohio-state.edu/cgi-bin/rfc/rfc2616.html
[4] http://httpd.apache.org/

Email author at [email protected]