Committer: aurbanowich
OPSC-156 Not working method Post in RPC apiU trunk/cgi-bin/LJ/Request/Apache.pm U trunk/cgi-bin/LJ/Request/Apache2.pm
Modified: trunk/cgi-bin/LJ/Request/Apache.pm =================================================================== --- trunk/cgi-bin/LJ/Request/Apache.pm 2010-09-03 08:09:46 UTC (rev 17276) +++ trunk/cgi-bin/LJ/Request/Apache.pm 2010-09-03 08:36:28 UTC (rev 17277) @@ -373,10 +373,19 @@ return @{ $self->{params} } if $self->{params}; my @params = $self->_parse_post(); + if(@params == 1){ + $self->{raw_content} = shift @params; + } $self->{params} = \@params; return @params; } +sub LJ::Request::raw_content { + my $class = shift; + my $self = $class->_get_instance(); + return if $self->post_params; + return $self->{raw_content}; +} sub LJ::Request::add_header_out { my $class = shift; @@ -473,13 +482,17 @@ my $apr = $class->apr(); my $method = $r->method; - return unless $method eq 'POST'; + return if $method eq 'GET'; # unless POST PUT DELETE HEAD my $host = $r->headers_in()->get("Host"); my $uri = $r->uri; ## apreq parses only this encoding methods. my $content_type = $r->headers_in()->get("Content-Type"); - if ($content_type !~ m!^application/x-www-form-urlencoded!i && + if ($content_type =~ m!^application/(json|xml)!i){ + my $content; + $apr->read($content, $r->headers_in()->get('Content-Length')) if $r->headers_in()->get('Content-Length'); + return $content; + }elsif ($content_type !~ m!^application/x-www-form-urlencoded!i && $content_type !~ m!^multipart/form-data!i) { ## hack: if this is a POST request, and App layer asked us @@ -491,6 +504,8 @@ } $r->headers_in()->set("Content-Type", "application/x-www-form-urlencoded"); } + + return unless $method eq 'POST'; my $qs = $r->args; $r->args(''); # to exclude GET params from Apache::Request object. Modified: trunk/cgi-bin/LJ/Request/Apache2.pm =================================================================== --- trunk/cgi-bin/LJ/Request/Apache2.pm 2010-09-03 08:09:46 UTC (rev 17276) +++ trunk/cgi-bin/LJ/Request/Apache2.pm 2010-09-03 08:36:28 UTC (rev 17277) @@ -418,6 +418,15 @@ return @params; } +sub LJ::Request::raw_content { + my $class = shift; + my $self = $class->_get_instance(); + my $r = $self->apr(); + return $self->{raw_content} if $self->{raw_content}; + $r->read($self->{raw_content}, $r->headers_in()->get('Content-Length')) if $r->headers_in()->get('Content-Length'); + return $self->{raw_content}; +} + sub LJ::Request::add_header_out { my $class = shift; my $header = shift;