sergot / http-useragent

Web user agent class for Perl 6.
MIT License
36 stars 39 forks source link

Incorrect content length due to eol appending #226

Open bbkr opened 5 years ago

bbkr commented 5 years ago

HTTP::Message in Str method is silently appending EOL:

https://github.com/sergot/http-useragent/blob/cfdfc48c55d312049f90f1db61042718c1de9908/lib/HTTP/Message.pm6#L231

This causes Content-Length calculated by user to be incorrect:

$response = HTTP::Response.new;
$response.set-code( 200 );

my $content = 'foo';   # 3 bytes
$response.add-content( $content );
$response.field( Content-Length => $content.encode.bytes );

$socket.print( $response.Str ); # will send 2 bytes more than declared

Why is this EOL appended? User content should not be tampered with. Is this behavior described somewhere in RFC?

zjmarlow commented 1 year ago

Can this please be fixed? Firefox Web Driver isn't handling the extra EOL.