Skip Menu |

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

Report information
The Basics
Id: 6636
Status: rejected
Priority: 0/
Queue: libwww-perl

People
Owner: Nobody in particular
Requestors: oleg [...] gryb.info
Cc:
AdminCc:

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



Subject: HTTP::Request::Common.pm bugs/problems
Perl v. 5.8.0 libwww-perl 5.79 module HTTP::Request::Common.pm, line 203: 1) unless ( -f $f && ($file_size = -s _) ) { '-s _' in this context always returns 0, as a result there is no Content-Length header for dynamic content. May be a problem for some servers. Can be changed to '-s $f' I think. 2) I'm not sure that the second one can be considered as a bug, but it definitely causes a problem when I work with Domino 4.6.7 web server. The problem is related to mime headers in multipart forms that are prepared by form_data function. It looks like the web server above expects exactly two headers and interprets everything else as data. As a result extra headers become a part of content and get uploaded to the server. It causes a real problem when you upload binary data. To fix this for my particular task I had to comment out the following lines (158,159) in Common.pm: #OG require LWP::MediaTypes; #OG $ct = LWP::MediaTypes::guess_media_type($file, $h); and get rid of extra empty line (171): my $head = join($CRLF, "Content-Disposition: $disp", $h->as_string($CRLF)); #OG $h->as_string($CRLF), #OG ""); After that everything started to work correctly. It would be great to have a flag that would allow to disable mime extensions. The second suggestion would be to remove the empty line that follows headers (but I'm not sure if the latter one will be compliant with RFC RFC1867)
From: Oleg
[guest - Wed Jun 16 03:15:35 2004]: Show quoted text
> Perl v. 5.8.0 > libwww-perl 5.79 > module HTTP::Request::Common.pm, line 203: > > 1) > unless ( -f $f && ($file_size = -s _) ) { > > '-s _' in this context always returns 0, as a result there is no > Content-Length header for dynamic content. May be a problem for > some servers. Can be changed to '-s $f' I think. > > 2) I'm not sure that the second one can be considered as a bug, but it > definitely causes a problem when I work with Domino 4.6.7 web > server. The problem is related to mime headers in multipart forms > that are prepared by form_data function. It looks like the web > server above expects exactly two headers and interprets everything > else as data. As a result extra headers become a part of content > and get uploaded to the server. It causes a real problem when you > upload binary data. To fix this for my particular task I had to > comment out the following lines (158,159) in Common.pm: > #OG require LWP::MediaTypes; > #OG $ct = LWP::MediaTypes::guess_media_type($file, $h); > > and get rid of extra empty line (171): > > my $head = join($CRLF, "Content-Disposition: $disp", > $h->as_string($CRLF)); > #OG $h->as_string($CRLF), > #OG ""); > > After that everything started to work correctly. > > It would be great to have a flag that would allow to disable mime > extensions. The second suggestion would be to remove the empty line > that follows headers (but I'm not sure if the latter one will be > compliant with RFC RFC1867)
Please disregard 1), it looks like it was something different, not related to '-s _' Number 2) is still valid
MIME type guessing can currently be disabled by not letting HTTP::Request::Common read the file itself. my $data = do { open(my $fh, $file) || die; local $/; <$fh> }; my $req = POST($url, Content_Type => "form-data", Content => { foo => 1, file => [undef, basename($file), Content => $data], } The trick is to pass 'undef' as the filename to read.
From: oleg [...] gryb.info
[GAAS - Mon Nov 15 16:02:35 2004]: Show quoted text
> MIME type guessing can currently be disabled by not letting > HTTP::Request::Common read the file itself. > > my $data = do { open(my $fh, $file) || die; local $/; <$fh> };
Thanks for the answer, but it doesn't look like a very good solution when you upload big files (100MB & more). I still think that having a flag would be a better solution
[guest - Tue Nov 16 10:50:22 2004]: Show quoted text
> [GAAS - Mon Nov 15 16:02:35 2004]: >
> > MIME type guessing can currently be disabled by not letting > > HTTP::Request::Common read the file itself. > > > > my $data = do { open(my $fh, $file) || die; local $/; <$fh> };
> Thanks for the answer, but it doesn't look like a very good solution > when you upload big files (100MB & more). I still think that having a > flag would be a better solution