Response (class)
Class Response
Implements methods for HTTP responses.
All of the following examples assume that $response
is an instance of this class.
Get header values
Header names are case-insensitive, but normalized to Title-Case when the response is parsed.
$val = $response->getHeaderLine('content-type');
Will read the Content-Type header. You can get all set headers using:
$response->getHeaders();
You can also get at the headers using object access. When getting headers with object access, you have to use case-sensitive header names:
$val = $response->headers['Content-Type'];
Get the response body
You can access the response body stream using:
$content = $response->getBody();
You can also use object access to get the string version of the response body:
登录查看完整内容