Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop transforming LF into CRLF. Fixes #69 #196

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
Loading