本文整理汇总了PHP中GuzzleHttp\Message\RequestInterface::removeHeader方法的典型用法代码示例。如果您正苦于以下问题:PHP RequestInterface::removeHeader方法的具体用法?PHP RequestInterface::removeHeader怎么用?PHP RequestInterface::removeHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GuzzleHttp\Message\RequestInterface
的用法示例。
在下文中一共展示了RequestInterface::removeHeader方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addContentLength
private function addContentLength(RequestInterface $request, StreamInterface $body)
{
// Set the Content-Length header if it can be determined, and never
// send a Transfer-Encoding: chunked and Content-Length header in
// the same request.
if ($request->hasHeader('Content-Length')) {
// Remove transfer-encoding if content-length is set.
$request->removeHeader('Transfer-Encoding');
return;
}
if ($request->hasHeader('Transfer-Encoding')) {
return;
}
if (null !== ($size = $body->getSize())) {
$request->setHeader('Content-Length', $size);
$request->removeHeader('Transfer-Encoding');
} elseif ('1.1' == $request->getProtocolVersion()) {
// Use chunked Transfer-Encoding if there is no determinable
// content-length header and we're using HTTP/1.1.
$request->setHeader('Transfer-Encoding', 'chunked');
$request->removeHeader('Content-Length');
}
}
示例2: signRequest
public function signRequest(RequestInterface $request, CredentialsInterface $credentials)
{
// Ensure that the signable query string parameters are sorted
sort($this->signableQueryString);
// Add the security token header if one is being used by the credentials
if ($token = $credentials->getSecurityToken()) {
$request->setHeader('X-Amz-Security-Token', $token);
}
// Add a date header if one is not set
$request->removeHeader('X-Amz-Date');
$request->setHeader('Date', gmdate(\DateTime::RFC2822));
$stringToSign = $this->createCanonicalizedString($request);
$request->getConfig()['aws.signature'] = $stringToSign;
$request->setHeader('Authorization', 'AWS ' . $credentials->getAccessKeyId() . ':' . $this->signString($stringToSign, $credentials));
}
示例3: moveHeadersToQuery
private function moveHeadersToQuery(RequestInterface $request)
{
$query = $request->getQuery();
foreach ($request->getHeaders() as $name => $header) {
$name = strtolower($name);
if (substr($name, 0, 5) == 'x-amz') {
$query[$name] = $header;
}
if ($name !== 'host') {
$request->removeHeader($name);
}
}
}