Skip Menu |
 

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

Report information
The Basics
Id: 49396
Status: resolved
Priority: 0/
Queue: libwww-perl

People
Owner: Nobody in particular
Requestors: aleksey.mashanov [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: multipart/* with no boundary
Download (untitled) / with headers
text/plain 1.8k
When multipart/* request is done, boundary for header 'Content-Type' is defined automatically, but too late, at time when headers are already prepared to send. Error is located in LWP::Protocol::http->request() or HTTP::Message logic, as you wish. 'boundary' part of content-type 'multipart/*' is generated on HTTP::Message->_content() call, but in LWP::Protocol::http code it's done only after headers are prepared. So, following lines of code must be reordered: my $request_headers = $request->headers->clone; $self->_fixup_header($request_headers, $url, $proxy); $request_headers->scan(sub { my($k, $v) = @_; $k =~ s/^://; $v =~ s/\n/ /g; push(@h, $k, $v); }); my $content_ref = $request->content_ref; Here ->content_ref calls ->_content and generates message-content and sets boundary. So it must be called before $request->headers->clone; Here located another incorrect behaviour. Some lines bellow Content-Length header is modified directly in @h, so if after request is done we call $response->request->header('Content-Length') we get value what wasn't really send. Code, on which I obtained this error is followed: my $ua = new LWP::UserAgent; my $req = new HTTP::Request( 'POST', $url ); $req->content_type( 'multipart/form-data' ); $req->header( 'Accept' => 'application/json' ); foreach my $file ( @list ) { my %info = %{ $file->{info} }; my $part = new HTTP::Message; $part->header( %info ); $part->content( $file->{content} ); $req->add_part( $part ); } # fixup for error in LWP::Protocol::http. # They set boundary of header Content-Type after headers are already serialized. # Here $req->_content() call is a dirty hack used to solve this problem. $req->_content(); my $res = $ua->request( $req );
Download (untitled) / with headers
text/plain 295b
This problem appears to have been fixed by this change (appeared in libwww-perl 5.826): commit c791df9d0f97df1befd6ef28ed49e20818c1d17a Author: Gisle Aas <gisle@aas.no> Date: Tue Mar 17 11:56:34 2009 +0100 Avoid returning stale Content-Type header after message parts have been updated


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.