初始化仓库
This commit is contained in:
43
vendor/guzzlehttp/guzzle-services/src/ResponseLocation/HeaderLocation.php
vendored
Normal file
43
vendor/guzzlehttp/guzzle-services/src/ResponseLocation/HeaderLocation.php
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace GuzzleHttp\Command\Guzzle\ResponseLocation;
|
||||
|
||||
use GuzzleHttp\Command\Guzzle\Parameter;
|
||||
use GuzzleHttp\Command\ResultInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
/**
|
||||
* Extracts headers from the response into a result fields
|
||||
*/
|
||||
class HeaderLocation extends AbstractLocation
|
||||
{
|
||||
/**
|
||||
* Set the name of the location
|
||||
*
|
||||
* @param string $locationName
|
||||
*/
|
||||
public function __construct($locationName = 'header')
|
||||
{
|
||||
parent::__construct($locationName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ResultInterface
|
||||
*/
|
||||
public function visit(
|
||||
ResultInterface $result,
|
||||
ResponseInterface $response,
|
||||
Parameter $param
|
||||
) {
|
||||
// Retrieving a single header by name
|
||||
$name = $param->getName();
|
||||
if ($header = $response->getHeader($param->getWireName())) {
|
||||
if (is_array($header)) {
|
||||
$header = array_shift($header);
|
||||
}
|
||||
$result[$name] = $param->filter($header);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user