Skip Menu |

This queue is for tickets about the libwww-perl CPAN distribution.

Report information
The Basics
Id: 86439
Status: open
Priority: 0/
Queue: libwww-perl

People
Owner: Nobody in particular
Requestors: kain.winterheart [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 6.05
Fixed in: (no value)



Subject: Troubles sending binary data via LWP::UserAgent::post
Hello. I have following code: use strict; use warnings; use LWP::UserAgent (); use URI (); use URI::Escape (); use Storable (); use Data::Dumper 'Dumper'; my $value = [ "hi" ]; my $initial_s = URI::Escape::uri_escape( Storable::freeze( $value ) ); print $initial_s . "\n"; my $u = URI -> new( 'http://somedomain/rpc/set?key=123&value=' . $initial_s . '&xt=60' ); my %args = $u -> query_form( undef ); $u = $u -> as_string(); print URI::Escape::uri_escape( $args{ 'value' } ) . "\n"; LWP::UserAgent -> new() -> post( $u, Content_Type => 'application/x-www-form-urlencoded', Content => [ %args ] ); my $s = LWP::UserAgent -> new() -> get( 'http://somedomain/123' ) -> content(); print URI::Escape::uri_escape( $s ) . "\n"; print Dumper( Storable::thaw( $s ) ); exit 0; which POSTs some binary data to our Kyoto Tycoon server and then retrives it. In LWP::UserAgent 5.835 this code works well: I am able to POST data, then GET it back, and it is still the same data I've sent initially. But in LWP::UserAgent 6.05 when I'm GETting my data back - it differs from the initial value. There is no troubles with Kyoto Tycoon as there is no problems LWP::UserAgent::get as I can see, but it seems that there is some trouble with LWP::UserAgent::post because following code works well: use strict; use warnings; use LWP::UserAgent (); use URI::Escape (); use Storable (); use Data::Dumper 'Dumper'; my $value = [ "hi" ]; my $initial_s = URI::Escape::uri_escape( Storable::freeze( $value ) ); print $initial_s . "\n"; my $cmd = 'curl -X POST -s "http://somedomain/rpc/set?key=123&value=' . $initial_s . '&xt=60"'; system( $cmd ); my $s = LWP::UserAgent -> new() -> get( 'http://somedomain/123' ) -> content(); print URI::Escape::uri_escape( $s ) . "\n"; print Dumper( Storable::thaw( $s ) ); exit 0; And, of course, as well as the code above, following code also work: use strict; use warnings; use LWP::UserAgent (); use URI::Escape (); use Storable (); use Data::Dumper 'Dumper'; my $value = [ "hi" ]; my $initial_s = URI::Escape::uri_escape( Storable::freeze( $value ) ); print $initial_s . "\n"; my $cmd = 'curl -X POST -s "http://somedomain/rpc/set?key=123&value=' . $initial_s . '&xt=60"'; system( $cmd ); my $s = `curl -s -o - http://somedomain/123`; print URI::Escape::uri_escape( $s ) . "\n"; print Dumper( Storable::thaw( $s ) ); exit 0; There is a note that initial code failures depend on $initial_s contents. I.e. it fails with serialized [ "hi" ], but works well with [ 1, 2, 3 ]. Could that be fixed somehow, or should I change my code?
Seems that this is the same bug as https://rt.cpan.org/Public/Bug/Display.html?id=75592 . Срд Июн 26 10:38:18 2013, https://www.google.com/accounts/o8/id?id=AItOawmNaaaSXM6QuPiIhzjO159qgjtY8HlNP64 писал: Show quoted text
> Hello. > > I have following code: > > > use strict; > use warnings; > > > use LWP::UserAgent (); > > use URI (); > use URI::Escape (); > > use Storable (); > use Data::Dumper 'Dumper'; > > > my $value = [ "hi" ]; > > my $initial_s = URI::Escape::uri_escape( Storable::freeze( $value ) ); > > print $initial_s . "\n"; > > my $u = URI -> new( 'http://somedomain/rpc/set?key=123&value=' . > $initial_s . '&xt=60' ); > > my %args = $u -> query_form( undef ); > > $u = $u -> as_string(); > > print URI::Escape::uri_escape( $args{ 'value' } ) . "\n"; > > LWP::UserAgent -> new() -> post( $u, Content_Type => 'application/x- > www-form-urlencoded', Content => [ %args ] ); > > my $s = LWP::UserAgent -> new() -> get( 'http://somedomain/123' ) -> > content(); > > print URI::Escape::uri_escape( $s ) . "\n"; > > print Dumper( Storable::thaw( $s ) ); > > exit 0; > > > which POSTs some binary data to our Kyoto Tycoon server and then > retrives it. > > In LWP::UserAgent 5.835 this code works well: I am able to POST data, > then GET it back, and it is still the same data I've sent initially. > But in LWP::UserAgent 6.05 when I'm GETting my data back - it differs > from the initial value. > > There is no troubles with Kyoto Tycoon as there is no problems > LWP::UserAgent::get as I can see, but it seems that there is some > trouble with LWP::UserAgent::post because following code works well: > > > use strict; > use warnings; > > > use LWP::UserAgent (); > > use URI::Escape (); > > use Storable (); > > use Data::Dumper 'Dumper'; > > > my $value = [ "hi" ]; > > my $initial_s = URI::Escape::uri_escape( Storable::freeze( $value ) ); > > print $initial_s . "\n"; > > my $cmd = 'curl -X POST -s "http://somedomain/rpc/set?key=123&value=' > . $initial_s . '&xt=60"'; > > system( $cmd ); > > my $s = LWP::UserAgent -> new() -> get( 'http://somedomain/123' ) -> > content(); > > print URI::Escape::uri_escape( $s ) . "\n"; > > print Dumper( Storable::thaw( $s ) ); > > exit 0; > > > And, of course, as well as the code above, following code also work: > > > use strict; > use warnings; > > > use LWP::UserAgent (); > > use URI::Escape (); > > use Storable (); > > use Data::Dumper 'Dumper'; > > > my $value = [ "hi" ]; > > my $initial_s = URI::Escape::uri_escape( Storable::freeze( $value ) ); > > print $initial_s . "\n"; > > my $cmd = 'curl -X POST -s "http://somedomain/rpc/set?key=123&value=' > . $initial_s . '&xt=60"'; > > system( $cmd ); > > my $s = `curl -s -o - http://somedomain/123`; > > print URI::Escape::uri_escape( $s ) . "\n"; > > print Dumper( Storable::thaw( $s ) ); > > exit 0; > > > There is a note that initial code failures depend on $initial_s > contents. I.e. it fails with serialized [ "hi" ], but works well with > [ 1, 2, 3 ]. > > Could that be fixed somehow, or should I change my code?