Subject: | HTTP::Headers clobbers field names |
The modperl test suite uses LWP and thus also HTTP::Headers. With the new version it started
to fail. The web server sends a custom response header named "X-err_headers_out". According to
RFC2616 this is a valid name.
To find the bug I have instrumented your code a bit:
sub _header
{
my($self, $field, $val, $op) = @_;
warn "\n\n\n=== field=$field, op=$op";
unless ($field =~ /^:/) {
$field =~ tr/_/-/ if $TRANSLATE_UNDERSCORE;
my $old = $field;
$field = lc $field;
unless(defined $standard_case{$field}) {
# generate a %standard_case entry for this field
$old =~ s/\b(\w)/\u$1/g;
$standard_case{$field} = $old;
}
}
warn "=== field=$field, op=$op";
...
When the response comes in I see the following conversion:
=== field=X-err_headers_out, op=PUSH_H at /.../HTTP/Headers.pm line 149.
=== field=x-err_headers_out, op=PUSH_H at /.../HTTP/Headers.pm line 162.
Later the header is accessed as "$res->header('X-err_headers_out')". This time I see:
=== field=X-err_headers_out, op=GET at /.../HTTP/Headers.pm line 149.
=== field=x-err-headers-out, op=GET at /.../HTTP/Headers.pm line 162.
Obviously, at PUSH time $TRANSLATE_UNDERSCORE is false. But when the header is to be read it
is true. Don't know why it started to fail with version 6.02. The code looks very similar to
5.xxx versions. But it did.
When I add a "local $HTTP::Headers::TRANSLATE_UNDERSCORE;" before the "$res->header('X-
err_headers_out')" all is well.