Skip to content

Commit 8dc5269

Browse files
Theo van Hoeseloalders
authored andcommitted
Include reason in response body content
1 parent e84475d commit 8dc5269

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

lib/HTTP/Daemon.pm

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,16 +299,18 @@ READ_HEADER:
299299
# check that they are all numbers (RFC: Content-Length = 1*DIGIT)
300300
my @nums = grep { /^[0-9]+$/} @vals;
301301
unless (@vals == @nums) {
302-
$self->send_error(400);
303-
$self->reason("Content-Length value must be a unsigned integer");
302+
my $reason = "Content-Length value must be an unsigned integer";
303+
$self->send_error(400, $reason);
304+
$self->reason($reason);
304305
return;
305306
}
306307
# check they are all the same
307308
my $ct_len = shift @nums;
308309
foreach (@nums) {
309310
next if $_ == $ct_len;
310-
$self->send_error(400);
311-
$self->reason("Content-Length values are not the same");
311+
my $reason = "Content-Length values are not the same";
312+
$self->send_error(400, $reason);
313+
$self->reason($reason);
312314
return;
313315
}
314316
# ensure we have now a fixed header, with only 1 value

0 commit comments

Comments
 (0)