On Thu Nov 21 10:35:23 2019, TEAM wrote:
Show quoted text> `$_[0]` there would need to be something like `$_[0] =~ s{^:}{}r`
> instead.
Probably safest to unpack @_ then mutate my own lexicals, in case ->scan is aliasing something existing in there.
--
Paul Evans
=== modified file 'lib/Net/Async/HTTP/Connection.pm'
--- old/lib/Net/Async/HTTP/Connection.pm 2019-02-17 14:13:09 +0000
+++ new/lib/Net/Async/HTTP/Connection.pm 2019-11-26 09:28:01 +0000
@@ -298,7 +298,11 @@
my $protocol = $req->protocol || "HTTP/1.1";
my @headers = ( "$method $path $protocol" );
- $headers->scan( sub { push @headers, "$_[0]: $_[1]" } );
+ $headers->scan( sub {
+ my ( $name, $value ) = @_;
+ $name =~ s/^://; # non-canonical header
+ push @headers, "$name: $value";
+ } );
$stall_timer->start if $stall_timer;
$stall_timer->reason = "writing request" if $stall_timer;
=== modified file 't/01request.t'
--- old/t/01request.t 2018-10-12 17:47:11 +0000
+++ new/t/01request.t 2019-11-26 09:28:01 +0000
@@ -568,4 +568,20 @@
expect_error => 1,
);
+do_test_req( "Non-canonical header",
+ req => HTTP::Request->new( GET => "/", [ ":other_hdr" => "value" ] ),
+ host => "myhost",
+
+ expect_req_firstline => "GET / HTTP/1.1",
+ expect_req_headers => {
+ other_hdr => "value",
+ },
+
+ response => "HTTP/1.1 200 OK$CRLF" .
+ "Content-Length: 0$CRLF" .
+ $CRLF,
+
+ expect_res_code => 200,
+);
+
done_testing;