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

Owner: Nobody in particular
Requestors: leonerd-cpan [...]

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

Subject: HTTP::Response constructor to set Content-Length
MIME-Version: 1.0
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
Message-ID: <rt-4.0.18-21711-1441812817-1089.0-0-0 [...]>
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 903
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
X-RT-Interface: REST
MIME-Version: 1.0
X-Mailer: MIME-tools 5.504 (Entity 5.504)
RT-Message-ID: <rt-4.0.18-21708-1490921812-853.106990-0-0 [...]>
Content-Type: text/plain; charset="utf-8"
Content-Disposition: inline
Content-Transfer-Encoding: binary
Content-Length: 82

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

Please report any issues with to