[Twisted-web] Redirecting

Syver Enstad syver at inout.no
Tue Jul 13 08:03:08 MDT 2004

Syver Enstad <syver at inout.no> writes:

> After reading up on the HTTP spec I found that one had to present a
> complete URL for the location header, although the browsers I use to
> test with (IE and Firefox) seems to accept just the path without
> protocol and hostname, there are tools (httpsession) that I am
> thinking of using for automated testing that doesn't.
> I thought of using request.prePathURL() but this seems to loose the
> session cookie if the hostname of the initial client request is
> something else than what prePathURL() returns. Example: an request for
> http://localhost/something/ will make request.prePathURL() answer
> http://myhostname/something/ and following the redirect loses the
> cookie.
> Is it generally accepted these days to not include hostname and
> protocol in location headers, if not how do I get the hostname from
> the request?

The reason I didn't get the hostname is that httpsession doesn't send
the host header. So prePathURL works as good as it can. I am still
curious as to whether it is common practice to send relative URL's in
the location header (it seems more elegant to me anyway).

More information about the Twisted-web mailing list