添加网站文件
This commit is contained in:
49
vendor/guzzlehttp/guzzle-services/src/RequestLocation/BodyLocation.php
vendored
Normal file
49
vendor/guzzlehttp/guzzle-services/src/RequestLocation/BodyLocation.php
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
namespace GuzzleHttp\Command\Guzzle\RequestLocation;
|
||||
|
||||
use GuzzleHttp\Command\CommandInterface;
|
||||
use GuzzleHttp\Command\Guzzle\Parameter;
|
||||
use GuzzleHttp\Psr7;
|
||||
use Psr\Http\Message\MessageInterface;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
|
||||
/**
|
||||
* Adds a body to a request
|
||||
*/
|
||||
class BodyLocation extends AbstractLocation
|
||||
{
|
||||
|
||||
/**
|
||||
* Set the name of the location
|
||||
*
|
||||
* @param string $locationName
|
||||
*/
|
||||
public function __construct($locationName = 'body')
|
||||
{
|
||||
parent::__construct($locationName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CommandInterface $command
|
||||
* @param RequestInterface $request
|
||||
* @param Parameter $param
|
||||
*
|
||||
* @return MessageInterface
|
||||
*/
|
||||
public function visit(
|
||||
CommandInterface $command,
|
||||
RequestInterface $request,
|
||||
Parameter $param
|
||||
) {
|
||||
$oldValue = $request->getBody()->getContents();
|
||||
|
||||
$value = $command[$param->getName()];
|
||||
$value = $param->getName() . '=' . $param->filter($value);
|
||||
|
||||
if ($oldValue !== '') {
|
||||
$value = $oldValue . '&' . $value;
|
||||
}
|
||||
|
||||
return $request->withBody(Psr7\stream_for($value));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user