本文整理汇总了PHP中Buzz\Message\Response::addHeader方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::addHeader方法的具体用法?PHP Response::addHeader怎么用?PHP Response::addHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Buzz\Message\Response
的用法示例。
在下文中一共展示了Response::addHeader方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testProcessSetCookieHeadersSetsCookies
public function testProcessSetCookieHeadersSetsCookies()
{
$request = new Message\Request();
$request->setHost('http://www.example.com');
$response = new Message\Response();
$response->addHeader('Set-Cookie: SESSION2=qwerty');
$response->addHeader('Set-Cookie: SESSION1=asdf');
$jar = new CookieJar();
$jar->processSetCookieHeaders($request, $response);
$cookies = $jar->getCookies();
$this->assertEquals(2, count($cookies));
foreach ($cookies as $cookie) {
$this->assertEquals('www.example.com', $cookie->getAttribute(Cookie::ATTR_DOMAIN));
$this->assertTrue(in_array($cookie->getName(), array('SESSION1', 'SESSION2')));
}
}
示例2: testGetReasonPhraseReturnsAMultiwordReasonPhrase
public function testGetReasonPhraseReturnsAMultiwordReasonPhrase()
{
$response = new Response();
$this->assertNull($response->getReasonPhrase());
$response->addHeader('HTTP/1.0 500 Internal Server Error');
$this->assertEquals('Internal Server Error', $response->getReasonPhrase());
}
示例3: createResponse
protected function createResponse($content = '')
{
$response = new Buzz\Message\Response();
$response->addHeader('1.0 200 OK');
$response->setContent($content);
return $response;
}
示例4: testSetsResponseHeadersAndContent
public function testSetsResponseHeadersAndContent()
{
$response = new Message\Response();
$response->addHeader('HTTP/1.0 200 OK');
$response->setContent('Hello World!');
$client = new FIFO();
$client->setQueue(array($response));
$client->sendToQueue($response);
$this->assertEquals(count($client->getQueue()), 2);
$request = new Message\Request();
$response = new Message\Response();
$client->send($request, $response);
$this->assertEquals(count($client->getQueue()), 1);
$this->assertEquals($response->getHeaders(), array('HTTP/1.0 200 OK'));
$this->assertEquals($response->getContent(), 'Hello World!');
}
示例5: onResult
/**
* {@inheritDoc}
*/
public function onResult(MultiCurl $client, RequestInterface $request, Response $response, array $options, $error)
{
if ($error !== CURLE_OK) {
$response->addHeader(sprintf('X-Curl-Error-Result: %d', $error));
}
}
示例6: createResponse
/**
* Create new Response.
*
* @param string $status response status description
* @param string $content content
*
* @return Message\Response
*/
protected function createResponse($status, $content = null)
{
$response = new Message\Response();
$response->addHeader($status);
if (null !== $content) {
$response->setContent($content);
}
return $response;
}