Skip to content

Commit

Permalink
Stop transforming LF into CRLF. Fixes #69
Browse files Browse the repository at this point in the history
  • Loading branch information
oalders committed Oct 4, 2024
1 parent db28013 commit 968789d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
3 changes: 0 additions & 3 deletions lib/HTTP/Request/Common.pm
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@ sub request_type_with_data
my $url = URI->new('http:');
$url->query_form(ref($content) eq "HASH" ? %$content : @$content);
$content = $url->query;

# HTML/4.01 says that line breaks are represented as "CR LF" pairs (i.e., `%0D%0A')
$content =~ s/(?<!%0D)%0A/%0D%0A/g if defined($content);
}
}

Expand Down
11 changes: 6 additions & 5 deletions t/common-req.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use strict;
use warnings;

use Test::More;
plan tests => 71;

use File::Spec;
use File::Temp qw(tempfile);
Expand Down Expand Up @@ -86,9 +85,9 @@ note $r->as_string, "\n";

is($r->method, "POST");
is($r->content_type, "application/x-www-form-urlencoded");
is($r->content_length, 83);
is($r->header("bar"), "foo");
is($r->content, "foo=bar%3Bbaz&baz=a&baz=b&baz=c&foo=zoo%3D%26&space+=+%2B+&nl=a%0D%0Ab%0D%0Ac%0D%0A");
is($r->content_length, 77, 'content_length');
is($r->header("bar"), "foo", 'bar is foo');
is($r->content, 'foo=bar%3Bbaz&baz=a&baz=b&baz=c&foo=zoo%3D%26&space+=+%2B+&nl=a%0Ab%0D%0Ac%0A');

$r = POST "http://example.com";
is($r->content_length, 0);
Expand Down Expand Up @@ -184,7 +183,7 @@ like($r->content, qr/bar=24/);
is($r->content_type, "application/x-www-form-urlencoded");
is($r->content_length, 13);


#
# POST for File upload
#
Expand Down Expand Up @@ -273,3 +272,5 @@ $r = HTTP::Request::Common::PATCH 'http://www.example.com',
'Content' => 'foobarbaz',
'Content-Length' => 12; # a slight lie
is($r->header('Content-Length'), 9);

done_testing();

0 comments on commit 968789d

Please sign in to comment.