Re: ConnCache not been used in LWP::UserAgent
Alexis Marrero <[EMAIL PROTECTED]> writes: > I'm trying to put together a short script to test a Keep-Alive > connection: > > # CODE BEGINS # > #!env perl -w > use strict; > > use LWP::UserAgent; > use LWP::ConnCache; > > my $browser = LWP::UserAgent->new(conn_cache => 1); This parameter is wrong, but should not really matter as it is overwritten in the next statement: > $browser->conn_cache(LWP::ConnCache->new()); > my @lines = ("mind is a terrible thing to waste\n") x 10; > my $start = time; > my $url = 'http://yourhost/yourpath'; > my $count = 0; > > foreach (@lines) { > my $response = $browser->post( $url, > [ 'pos' => $count, > 'block' => $_, > ], > 'Content_Type' => 'form-data', > ); > > $count += length $_; > } > > > print time() - $start; > print " secs\n"; > > # CODE ENDS # > > I noticed that when the request is made the HTTP headers don't > include "Connection: Keep-Alive". It does include "Connection: TE". 'Connection: Keep-Alive' is only used when talking to HTTP/1.0 servers. For HTTP/1.1 it shouldn't be used. > Reading the UserAgent.pm source code I noticed that the connection > cache is stored in $self->{conn_cache} but that value is never used > in the module. May be is used by reference in other places by > passing $self. Yes. It's picked up directly by LWP/Protocol/http.pm. > The point is that the client is opening connections for every request. Does not happen when I test your pogram against my server, so I do belive LWP does the right thing.. Regards, Gisle
Re: ConnCache not been used in LWP::UserAgent
Mea Culpa. The ConnCache object is been used in LWP::Protocol and its sub classes. How ever do one have to add the Connection: Keep-Alive header in the request anyway? /amn On Apr 19, 2006, at 9:56 AM, Alexis Marrero wrote: All, I'm trying to put together a short script to test a Keep-Alive connection: # CODE BEGINS # #!env perl -w use strict; use LWP::UserAgent; use LWP::ConnCache; my $browser = LWP::UserAgent->new(conn_cache => 1); $browser->conn_cache(LWP::ConnCache->new()); my @lines = ("mind is a terrible thing to waste\n") x 10; my $start = time; my $url = 'http://yourhost/yourpath'; my $count = 0; foreach (@lines) { my $response = $browser->post( $url, [ 'pos' => $count, 'block' => $_, ], 'Content_Type' => 'form-data', ); $count += length $_; } print time() - $start; print " secs\n"; # CODE ENDS # I noticed that when the request is made the HTTP headers don't include "Connection: Keep-Alive". It does include "Connection: TE". Reading the UserAgent.pm source code I noticed that the connection cache is stored in $self->{conn_cache} but that value is never used in the module. May be is used by reference in other places by passing $self. The point is that the client is opening connections for every request. /amn
ConnCache not been used in LWP::UserAgent
All, I'm trying to put together a short script to test a Keep-Alive connection: # CODE BEGINS # #!env perl -w use strict; use LWP::UserAgent; use LWP::ConnCache; my $browser = LWP::UserAgent->new(conn_cache => 1); $browser->conn_cache(LWP::ConnCache->new()); my @lines = ("mind is a terrible thing to waste\n") x 10; my $start = time; my $url = 'http://yourhost/yourpath'; my $count = 0; foreach (@lines) { my $response = $browser->post( $url, [ 'pos' => $count, 'block' => $_, ], 'Content_Type' => 'form-data', ); $count += length $_; } print time() - $start; print " secs\n"; # CODE ENDS # I noticed that when the request is made the HTTP headers don't include "Connection: Keep-Alive". It does include "Connection: TE". Reading the UserAgent.pm source code I noticed that the connection cache is stored in $self->{conn_cache} but that value is never used in the module. May be is used by reference in other places by passing $self. The point is that the client is opening connections for every request. /amn
Re: Base64 data: URLs vs url encoding
Bjoern Hoehrmann <[EMAIL PROTECTED]> writes: > Hi, > > print URI->new('data:;base64,QmpvZXJu')->data; > print URI->new('data:;base64,%51%6D%70%76%5A%58%4A%75')->data; > > I think this should both print "Bjoern", but in the second case the > module returns garbage (URI 1.35). Thanks for your report. I've applied the following patch to fix this bug: Index: URI/data.pm === RCS file: /cvsroot/libwww-perl/uri/URI/data.pm,v retrieving revision 4.4 diff -u -p -r4.4 data.pm --- URI/data.pm 14 Jan 2004 13:33:44 - 4.4 +++ URI/data.pm 19 Apr 2006 11:01:01 - @@ -55,7 +55,8 @@ sub data $self->opaque("$enc,$new"); } return unless defined wantarray; -return $base64 ? decode_base64($data) : uri_unescape($data); +$data = uri_unescape($data); +return $base64 ? decode_base64($data) : $data; } # I could not find a better way to interpolate the tr/// chars from Index: t/data.t === RCS file: /cvsroot/libwww-perl/uri/t/data.t,v retrieving revision 1.4 diff -u -p -r1.4 data.t --- t/data.t5 Aug 2003 15:27:49 - 1.4 +++ t/data.t19 Apr 2006 11:01:01 - @@ -9,7 +9,7 @@ if ($@) { exit; } -print "1..21\n"; +print "1..22\n"; use URI; @@ -106,3 +106,5 @@ $old = $u->data("new"); print "not " unless $old eq "" && $u eq "data:bar%2Cb%E5z,new"; print "ok 21\n"; +print "not " unless URI->new('data:;base64,%51%6D%70%76%5A%58%4A%75')->data eq "Bjoern"; +print "ok 22\n";