Skip Menu |
 

This queue is for tickets about the HTTP-Message CPAN distribution.

Report information
The Basics
Id: 106990
Status: resolved
Priority: 0/
Queue: HTTP-Message

People
Owner: Nobody in particular
Requestors: leonerd-cpan [...] leonerd.org.uk
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: HTTP::Response constructor to set Content-Length
Download (untitled) / with headers
text/plain 903b
Often it's convenient to send an HTTP response from an inline-constructed H:R object: $req->respond( HTTP::Response->new( 200, "OK", [ "Content-Type" => "text/plain" ], "Hello, world", ) ); Problem is if I do this, the response object has no Content-Length, no Connection=close and no chunked transfer encoding. The HTTP server/client now have no way to communicate the end of the response and the client will never see the end. It's not always convenient to store the content in a variable first, my $content = ... $req->respond( HTTP::Response->new( 200, "OK", [ "Content-Type" => "text/plain", "Content-Length" => length $content ], $content ) ); It might be nice to have a constructor to do this sub new_with_content_length { my $self = shift->new( @_ ); $self->content_length( length $self->content ) if defined $self->content; $self; } -- Paul Evans


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.