Re: empty headers

Austin S. Lin (austin@al2.com)
Fri, 26 Nov 1999 08:27:53 -0800 (PST)


Actually, I think this might be anti-social server behavior
requiring a cookie to be set before you do anything -- there is a
loop b/c LWP is following the redirect without sending back the
cookie:

 > Set-Cookie: ASPSESSIONIDGQGQGRWL=LNLFLAGBKEIGCCMPBLCJJJGN; path=/

If you use HTTP::Cookies, extract_cookies(), and
add_cookie_header(), I bet there is no longer a loop warning.

Btw, are there already plans to add default cookie support to
LWP? (Since there is support for following redirects, it wouldn't
be unreasonable to also have support for vanilla cookies.)

- Austin

On Nov 26, Priebe, Jason sprach thusly:

> I came across another poorly formed response that LWP doesn't
> seem to handle very well.  Here's an example:
> ----------------------------------------------------------------------
> > telnet www.cemacity.org 80
> Trying 38.201.123.205...
> Connected to cemacity.org.
> Escape character is '^]'.
> HEAD / HTTP/1.0
> 
> HTTP/1.1 302 Object moved
> Server: Microsoft-IIS/4.0
> Date: Fri, 26 Nov 1999 10:09:14 GMT
> : 9207358000
> Location: http://204.245.190.25/default.cfm
> Content-Type: text/html
> Set-Cookie: ASPSESSIONIDGQGQGRWL=LNLFLAGBKEIGCCMPBLCJJJGN; path=/
> Cache-control: private
> 
> Connection closed by foreign host.
> ----------------------------------------------------------------------
> 
> Notice the response header ": 920735800".  This causes LWP to not read
> the rest of the headers.  It reports "Client-Warning: Redirect loop
> detected"
> (I guess because it doesn't read the Location header).
> 
> I am attaching a patch to LWP/Protocol/http.pm that will allow it to
> read such poorly formed headers.  I'm not aware of the implications
> of this.  Will allowing these "empty headers" have a negative impact
> on other functions within LWP?
> 
> 197,199c197
> <               # patch by Jason Priebe <priebe@wral-tv.com> to allow
> <               # poorly formed headers of the form ": $val" (missing $key)
> <               if ($line =~ /^([a-zA-Z0-9_\-.]*)\s*:\s*(.*)/) {
> ---
> >               if ($line =~ /^([a-zA-Z0-9_\-.]+)\s*:\s*(.*)/) {
> 
> Jason Priebe
> WRAL OnLine
> http://www.wral-tv.com/
>