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

libwwwperl 5.61 doesn't handle Transfer-Encoding: Chunked

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

	http://www.paymentech.net/facelift/sol_pcsol_page.jsp

results in a response of

telnet www.paymentech.net 80^M
Trying 63.251.156.40...^M
Connected to www.paymentech.net.^M
Escape character is '^]'.^M
GET /facelift/sol_pcsol_page.jsp HTTP/1.1
Host: www.paymentech.net

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.

Best,
Blair

-- 
Blair Zajac <blair@orcaware.com> - Perl & sysadmin services for hire
Web and OS performance plots - http://www.orcaware.com/orca/
Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About