getBody()->detach(); if (!is_resource($resource)) { throw new InvalidResponseException('Response body is invalid.'); } return new self( $response->getStatusCode(), $response->getHeaders(), new StreamDecorator($resource), $response->getProtocolVersion(), $response->getReasonPhrase() ); } }