Skip to content

Incorrect content length due to eol appending #226

@bbkr

Description

@bbkr

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions