Merge pull request #173 from rhansen/request-body-crlf

Don't replace LF with CRLF in body of HTTP request
This commit is contained in:
Sandro 2020-06-14 15:59:18 +02:00 committed by GitHub
commit 35eac827e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2004,7 +2004,7 @@ sub geturl {
my $method = shift || 'GET';
my $data = shift || '';
my ($peer, $server, $port, $default_port, $use_ssl);
my ($sd, $rq, $request, $reply);
my ($sd, $request, $reply);
## canonify proxy and url
my $force_ssl;
@ -2063,10 +2063,11 @@ sub geturl {
$headers .= "\n" if $headers ne '' && substr($headers, -1) ne "\n";
$request .= $headers;
$request .= "\n";
# RFC 7230 says that all lines before the body must end with <cr><lf>.
(my $rq = $request) =~ s/(?<!\r)\n/\r\n/g;
$request .= $data;
$rq .= $data;
## make sure newlines are <cr><lf> for some pedantic proxy servers
($rq = $request) =~ s/\n/\r\n/g;
$0 = sprintf("%s - connecting to %s port %s", $program, $peer, $port);
if (!opt('exec')) {