本文整理匯總了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;
}