I am using the execute() method of HttpClient class to execute the HttpClientRequest and it works just fine.

But, I need the response code and response headers as they are required at times while working with the Google Data Protocol, especially with Documents List API.

How can I send a request using this module and get response code, response header and of course, response body at the same time?

Comments

voxpelli’s picture

The response code should be possible to find in the response object as "responseCode", the response message as "responseMessage", the headers as "headers" and the body as "body".

So doing a $client->get() should return an object with those properties so that you can check eg. $obj->responseCode to get the responseCode.

vaidik’s picture

Status: Active » Closed (fixed)

So with the help provided by voxpelli, I am doing this to achieve what I wanted to:

<?php
...
$http_client = new HttpClient($auth);
$request_values = array(
  'method' => 'POST',
  'parameters' => array(),
);
$request = new HttpClientRequest($url, $request_values);

$result['xml'] = $http_client->execute($request);

$lastResponse = $http_client->lastResponse;
$result['response_code'] = $lastResponse->responseCode;
$result['headers'] = $lastResponse->headers;
?>

Thanks a lot for the help.