Skip to content

Commit

Permalink
Merge pull request #8562 from ehuelsmann/fix/1.12/get-with-content_type
Browse files Browse the repository at this point in the history
Ignore 'Content-Type' header if there's no body
  • Loading branch information
ehuelsmann authored Jan 2, 2025
2 parents 486b9f1 + f505f11 commit ed260fe
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/LedgerSMB/Router.pm
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,8 @@ sub api {
my $schema = $settings->api_validator;
my $req = Plack::Request::WithEncoding->new($env);
my $has_body = ($req->headers->content_length() // 0) > 0;
my $body = ($req->headers->content_type eq 'application/json') ?
my $content_type = $has_body ? $req->headers->content_type : '';
my $body = ($has_body and $content_type eq 'application/json') ?
json()->decode($req->content) : '';
# bug: multipart/form-data wants to be validated and
# so does application/x-www-form-urlencoded
Expand All @@ -493,7 +494,7 @@ sub api {
path => $params,
header => { $req->headers->psgi_flatten->@* },
query => $req->query_parameters->as_hashref_mixed,
body => [ $has_body, $req->headers->content_type, $body ]
body => [ $has_body, $content_type, $body ]
});
if (scalar(@$errors) > 0) {
my ($err) = @$errors;
Expand Down

0 comments on commit ed260fe

Please sign in to comment.