public function Request::setResponseBody

Set the EntityBody that will hold the response message's entity body.

This method should be invoked when you need to send the response's entity body somewhere other than the normal php://temp buffer. For example, you can send the entity body to a socket, file, or some other custom stream.

Parameters

EntityBodyInterface|string|resource $body Response body object. Pass a string to attempt to store the: response body in a local file.

Return value

Request

Overrides RequestInterface::setResponseBody

File

drupal/core/vendor/guzzle/http/Guzzle/Http/Message/Request.php, line 546

Class

Request
HTTP request class to send requests

Namespace

Guzzle\Http\Message

Code

public function setResponseBody($body) {

  // Attempt to open a file for writing if a string was passed
  if (is_string($body)) {

    // @codeCoverageIgnoreStart
    if (!($body = fopen($body, 'w+'))) {
      throw new InvalidArgumentException('Could not open ' . $body . ' for writing');
    }

    // @codeCoverageIgnoreEnd
  }
  $this->responseBody = EntityBody::factory($body);
  return $this;
}