| 504 | | |
| | 504 | my $host = $r->headers_in()->get("Host"); |
| | 505 | my $uri = $r->uri; |
| | 506 | |
| | 507 | ## apreq parses only this encoding methods. |
| | 508 | my $content_type = $r->headers_in()->get("Content-Type"); |
| | 509 | if ($content_type !~ m!^application/x-www-form-urlencoded!i && |
| | 510 | $content_type !~ m!^multipart/form-data!i) |
| | 511 | { |
| | 512 | ## hack: if this is a POST request, and App layer asked us |
| | 513 | ## for params, pretend that encoding is default 'application/x-www-form-urlencoded' |
| | 514 | ## Some clients that use flat protocol issue malformed headers, |
| | 515 | ## so don't even make a warn. |
| | 516 | if ($uri ne '/interface/flat') { |
| | 517 | warn "Changing content-type of POST ($host$uri) from $content_type to default"; |
| | 518 | } |
| | 519 | $r->headers_in()->set("Content-Type", "application/x-www-form-urlencoded"); |
| | 520 | } |
| | 521 | |
| 509 | | |
| 510 | | ## apreq parses only this encoding methods. |
| 511 | | my $content_type = $r->headers_in()->get("Content-Type"); |
| 512 | | if ($content_type =~ m!^application/x-www-form-urlencoded!i or |
| 513 | | $content_type =~ m!^multipart/form-data!i |
| 514 | | ){ |
| 515 | | my $parse_res = $instance->{apr}->parse; |
| 516 | | if ($parse_res eq OK){ |
| 517 | | $instance->{post_parsed_successfully} = 1; |
| 518 | | } else { |
| 519 | | $instance->{post_parsed_successfully} = 0; |
| 520 | | warn "Can't parse post data: content-type=" . $r->headers_in()->get("Content-Type") . " uri=" . $r->uri . "?" . $qs; |
| 521 | | } |
| 522 | | } |
| 523 | | |
| | 526 | |
| | 527 | my $parse_res = $instance->{apr}->parse; |