Skip to content

Commit

Permalink
Added getHeaders method to the ResponseInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverFire committed Jan 27, 2017
1 parent 64d485c commit 140aa1b
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/ResponseInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,21 @@ public function getRawData();
*/
public function getHeader($name);

/**
* Returns an associative array of the message's headers
* Key - Header name
* Value - array of header values. For example:
*
* ```php
* ['Location' => ['http://example.com'], 'Expires' => ['Thu, 01 Jan 1970 00:00:00 GMT']]
* ```
*
* @return string[][] Returns an associative array of the message's headers. Each
* key MUST be a header name, and each value MUST be an array of strings
* for that header.
*/
public function getHeaders();

/**
* @return string
*/
Expand Down
14 changes: 14 additions & 0 deletions src/curl/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,18 @@ protected function checkTransportError($error, $errorCode)
throw new ResponseErrorException($error, $this, $errorCode);
}
}

/**
* Returns array of all headers.
* Key - Header name
* Value - array of header values. For example:
*
* ```php
* ['Location' => ['http://example.com'], 'Expires' => ['Thu, 01 Jan 1970 00:00:00 GMT']]
* @return array
*/
public function getHeaders()
{
return $this->headers;
}
}
5 changes: 5 additions & 0 deletions src/proxy/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public function getStatusCode()
return $this->worker->getStatusCode();
}

public function getHeaders()
{
return $this->worker->getHeaders();
}

public function getReasonPhrase()
{
return $this->worker->getReasonPhrase();
Expand Down
5 changes: 5 additions & 0 deletions src/stream/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public function getHeader($name)
return isset($this->headers[$name]) ? $this->headers[$name] : null;
}

public function getHeaders()
{
return $this->headers;
}

public function parseHeaders($headers)
{
$result = [];
Expand Down

0 comments on commit 140aa1b

Please sign in to comment.