Re: how to extract the "body" of a HTTP_Request2 request?
| From: | Bill Shupp | Date: | Wed, 03 Mar 2010 23:30:00 +0000 |
| Subject: | Re: how to extract the "body" of a HTTP_Request2 request? | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-30354@lists.php.net to get a copy of this message | ||
On Mar 3, 2010, at 3:13 PM, Robert P. J. Day wrote:
>
> just getting started with the HTTP_Request2 class, and i want to
> create a POST request that passes potentially lots of data as uploaded
> content. from the class definition in Request2.php, i can see:
>
> /**
> * Sets the request body
> *
> * @param string Either a string with the body or filename containing body
> * @param bool Whether first parameter is a filename
> * @return HTTP_Request2
> * @throws HTTP_Request2_Exception
> */
> public function setBody($body, $isFilename = false)
> ... snip ...
>
>
> fair enough but, once i send off the POST request to the remote PHP
> file, how do i access that "body" content? i'm sure this is just a
> trivial POST issue. i can examine $_SERVER['CONTENT_LENGTH'] to see
> the *length* of the body, but i don't know what variable to use to get
> the content itself. help?
>
> rday
$http = new HTTP_Request2('http://example.com');
$response = $http->send();
$body = $response->getBody();
Regards,
Bill