develooper Front page | perl.libwww | Postings from November 2001

libwwwperl 5.61 doesn't handle Transfer-Encoding: Chunked

Thread Next
Blair Zajac
November 17, 2001 22:58
libwwwperl 5.61 doesn't handle Transfer-Encoding: Chunked
Message ID:
The code that handles Transfer-Encoding's only matches on lowercase header
values.  A HTTP/1.1 request for the page

results in a response of

telnet 80^M
Connected to^M
Escape character is '^]'.^M
GET /facelift/sol_pcsol_page.jsp HTTP/1.1

HTTP/1.1 200 OK
Date: Sun, 18 Nov 2001 06:54:55 GMT
Server: WebLogic 6.0 Service Pack 2 05/24/2001 11:55:28 #117037
Content-Type: text/html
Connection: Keep-Alive
Transfer-Encoding: Chunked
Set-Cookie: JSESSIONID=O1dbP0c0rlTJTHF8y62bxVs1f1uvKskAKRnMTMpa5OnKeX3jDDLp!8773
487694517038762!167772202!80!443; path=/

note that Chunked is capatilized.

When requested using HTTP/1.1 connections in libwww-perl, you get a 500
"Internal Server Error" page returned to the browser saying: "Chunked must be
last Transfer-Encoding 'Chunked'".

The code in lib/Net/HTTP/Methods has this:

        elsif (my $te = ${*$self}{'http_te'}) {
            my @te = split(/\s*,\s*/, $te);
            die "Chunked must be last Transfer-Encoding '$te'"
                unless pop(@te) eq "chunked";

            for (@te) {
                if ($_ eq "deflate" && zlib_ok()) {
                    #require Compress::Zlib;
                    my $i = Compress::Zlib::inflateInit();
                    die "Can't make inflator" unless $i;
                    $_ = sub { scalar($i->inflate($_[0])) }

I don't know if you just want to add a

	$_ = lc($_);

before all of the tests, or do something more complicated, as the attached patch
does.  It uses lc($_) instead of a presumably slower $_ =~ /^chunked$/ and it
also checks for the rest of the header values.


Blair Zajac <> - Perl & sysadmin services for hire
Web and OS performance plots -
Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About