incorrect HTTP header parsing in http.pm

Marc Langheinrich (marc@ccm.cl.nec.co.jp)
Wed, 3 Feb 1999 10:40:21 +0900 (JST)


I ran into some problems dealing with HTTP headers that contain a dot
"."  when using the LWP library. I double checked the HTTP draft (both
1.1 and 1.0) and it defines an HTTP header name as being a "token":

  token      = 1*<any CHAR except CTLs or separators>
  separators = "(" | ")" | "<" | ">" | "@" |
               "," | ";" | ":" | "\" | <"> |
               "/" | "[" | "]" | "?" | "=" |
               "{" | "}" | SP | HT

Anyways, a dot "." seems to be an accepted character. But http.pm
flags it as a "Client-Warning: Illegal Header". Below is a (laughable) 
patch that fixes http.pm to accept dots "." in header names...

Marc


*** http.pm     Wed Feb  3 10:04:02 1999
--- http.pm.old Wed Feb  3 10:02:08 1999
***************
*** 194,200 ****
                $line =~ s/\015$//;
                last unless length $line;
  
!               if ($line =~ /^([a-zA-Z0-9_\-.]+)\s*:\s*(.*)/) {
                    $response->push_header($key, $val) if $key;
                    ($key, $val) = ($1, $2);
                } elsif ($line =~ /^\s+(.*)/) {
--- 194,200 ----
                $line =~ s/\015$//;
                last unless length $line;
  
!               if ($line =~ /^([a-zA-Z0-9_\-]+)\s*:\s*(.*)/) {
                    $response->push_header($key, $val) if $key;
                    ($key, $val) = ($1, $2);
                } elsif ($line =~ /^\s+(.*)/) {