當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Response::addHeader方法代碼示例

本文整理匯總了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')));
     }
 }
開發者ID:ChazalFlorian,項目名稱:enjoyPangolin,代碼行數:16,代碼來源:CookieJarTest.php

示例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());
 }
開發者ID:ChazalFlorian,項目名稱:enjoyPangolin,代碼行數:7,代碼來源:ResponseTest.php

示例3: createResponse

 protected function createResponse($content = '')
 {
     $response = new Buzz\Message\Response();
     $response->addHeader('1.0 200 OK');
     $response->setContent($content);
     return $response;
 }
開發者ID:pampy,項目名稱:PiwikClient,代碼行數:7,代碼來源:HttpConnectionTest.php

示例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!');
 }
開發者ID:philip,項目名稱:Buzz,代碼行數:16,代碼來源:FIFOTest.php

示例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));
     }
 }
開發者ID:vaniocz,項目名稱:VanioBuzzBundle,代碼行數:9,代碼來源:ErrorListener.php

示例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;
    }
開發者ID:ezsystemstraining,項目名稱:ez54training,代碼行數:19,代碼來源:ConnectionTest.php


注:本文中的Buzz\Message\Response::addHeader方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。