Skip Menu |
 

This queue is for tickets about the HTTP-Message CPAN distribution.

Report information
The Basics
Id: 67258
Status: rejected
Priority: 0/
Queue: HTTP-Message

People
Owner: Nobody in particular
Requestors: OPI [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 6.02
Fixed in: (no value)



Subject: HTTP::Headers clobbers field names
Download (untitled) / with headers
text/plain 1.4k
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.
Download (untitled) / with headers
text/plain 520b
I do regret that we added the $TRANSLATE_UNDERSCORE feature, but it's the documented interface and I think you will have to live with it. If you pass underscores to $res->header() that you want to be treated like underscores you have to wrap your code in a block with "local $HTTP::Headers::TRANSLATE_UNDERSCORE;". LWP::UserAgent will always unset TRANSLATE_UNDERSCORE while parsing HTTP headers. It's done that "forever", so I can't really understand either why you only see this failure after upgrading to 6.02.
Download (untitled) / with headers
text/plain 913b
On 2012-02-16 16:42:54, GAAS wrote: Show quoted text
> I do regret that we added the $TRANSLATE_UNDERSCORE feature, but it's > the documented interface and I think you will have to live with it. > If you pass > underscores to $res->header() that you want to be treated like > underscores you have to wrap your code in a block with "local > $HTTP::Headers::TRANSLATE_UNDERSCORE;". > > LWP::UserAgent will always unset TRANSLATE_UNDERSCORE while parsing > HTTP headers. It's done that "forever", so I can't really understand > either why you > only see this failure after upgrading to 6.02.
Just a cross-reference: mod_perl 2 seems to be a "victim" of this change, see: https://metacpan.org/source/PHRED/mod_perl-2.0.8/t/api/err_headers_out.t#L22 (Actually, the test still fails for HTTP::Headers > 6.00; it looks like the mod_perl authors regarded this as a bug in HTTP::Headers, and expected a fix in 6.01) Regards, Slaven


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.