Skip to content

Commit

Permalink
Include reason in response body content
Browse files Browse the repository at this point in the history
  • Loading branch information
Theo van Hoesel authored and oalders committed Jun 27, 2022
1 parent e84475d commit 8dc5269
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/HTTP/Daemon.pm
Expand Up @@ -299,16 +299,18 @@ READ_HEADER:
# check that they are all numbers (RFC: Content-Length = 1*DIGIT)
my @nums = grep { /^[0-9]+$/} @vals;
unless (@vals == @nums) {
$self->send_error(400);
$self->reason("Content-Length value must be a unsigned integer");
my $reason = "Content-Length value must be an unsigned integer";
$self->send_error(400, $reason);
$self->reason($reason);
return;
}
# check they are all the same
my $ct_len = shift @nums;
foreach (@nums) {
next if $_ == $ct_len;
$self->send_error(400);
$self->reason("Content-Length values are not the same");
my $reason = "Content-Length values are not the same";
$self->send_error(400, $reason);
$self->reason($reason);
return;
}
# ensure we have now a fixed header, with only 1 value
Expand Down

0 comments on commit 8dc5269

Please sign in to comment.