Skip to content

Please add a "fix content length" mutator #136

@leonerd

Description

@leonerd

99% of the time I create an HTTP::Response I forget to set the Content-Length header, thus stalling the HTTP pipeline. To fix this one simply has to remember to

$resp->content_length( length $resp->content );

Which is reasonable enough if you have the response in a variable. However, #135 wishes to add chaining mutators in order to support fully-constructing a response object in a single expression without needing such a temporary. Without it it becomes hard to fix the content length.

I'd therefore suggest either a special "fix the content length" method, or else the default behaviour of a ->set_content_length method with no additional arguments, to do this.

return HTTP::Response->new( 200 )
    ->set_content( join "\n", @lines )
    ->set_content_length;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions