Subject: | Posted binary-data is broken |
Date: | Wed, 14 Jan 2009 17:45:46 +0900 |
To: | <bug-libwww-perl [...] rt.cpan.org> |
From: | "uchino" <m-uchino [...] yetipapa.com> |
(Sorry, my English is poor.)
Binary-data which posted by LWP::UserAgent with SSL is broken.
This problem occurs when using SSL and UTF-8-Flag of added header is
set to ON.
[EXAMPLE]
----------------------------------------------------------------------
----
#!/usr/local/bin/perl
use strict;
use utf8; # ******** (1)
use LWP::UserAgent;
use HTTP::Request::Common 'POST';
my $ua = LWP::UserAgent->new();
my $http_res = $ua->request(POST 'https://myhost/post.cgi', # ********
(2)
Content_Type => 'form-data',
Content => [
bin_data => ['./image.gif'],
],
Head1 => 'A', # ******** (3)
);
$http_res->is_success or die $http_res->message;
print "OK\n";
exit;
----------------------------------------------------------------------
----
[post.cgi CHECK SCRIPT]
----------------------------------------------------------------------
----
#!/usr/local/bin/perl
use strict;
my $buffer;
binmode STDIN, ':raw';
read(STDIN, $buffer, $ENV{CONTENT_LENGTH});
open my $fh, '>:raw', './request_body.dat' or die($!);
print $fh $buffer;
close $fh;
print "Content-type: text/plain\n\nOK";
exit;
----------------------------------------------------------------------
----
A header-name is 'Head1'(3). UTF-8-Flag of this text is set to ON by
'use utf8'(1).
Post to SSL site(2).
Check the file(request_body.dat) by binary-editor.
Data and boundary are broken.
'Head1' is ASCII characters, but it's not-quoted and UTF-8-Flag is set
to ON.
If it's quoted, this problem don't occur.
'Head1' => 'A', # ******** (3)
This problem in Crypt::SSLeay?
Perl v5.8.8
libwww v5.823
Crypt::SSLeay v0.57