当前位置: 首页>>代码示例>>PHP>>正文


PHP Message\Response类代码示例

本文整理汇总了PHP中Buzz\Message\Response的典型用法代码示例。如果您正苦于以下问题:PHP Response类的具体用法?PHP Response怎么用?PHP Response使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Response类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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

示例2: createResponse

 private function createResponse($content, $statusCode = 200)
 {
     $response = new Response();
     $response->setContent($content);
     $response->setHeaders(array('HTTP/1.1 ' . $statusCode . ' REASON'));
     return $response;
 }
开发者ID:wjzijderveld,项目名称:youless-client,代码行数:7,代码来源:ClientSpec.php

示例3: testAddHeadersResetsStatusLine

 public function testAddHeadersResetsStatusLine()
 {
     $response = new Response();
     $this->assertNull($response->getStatusCode());
     $response->addHeaders(array('1.0 200 OK'));
     $this->assertEquals(200, $response->getStatusCode());
 }
开发者ID:kingsj,项目名称:core,代码行数:7,代码来源:ResponseTest.php

示例4: __construct

 public function __construct(TransportResponse $response)
 {
     if (!$response->isSuccessful()) {
         throw new TransportException($response);
     }
     $this->response = $response;
 }
开发者ID:markey-magic,项目名称:tractionphp,代码行数:7,代码来源:Response.php

示例5: verifyResult

 /**
  * Verifies the last request.
  * If the last request was not successful, it will be throw an exception.
  *
  * @param \Buzz\Message\Response $response The response object from the last reques
  * @param string $url The url which was requested
  * @return \Buzz\Message\Response
  * @throws \Exception
  */
 protected function verifyResult(\Buzz\Message\Response $response, $url)
 {
     if ($response->getStatusCode() !== 200) {
         throw new \Exception('Request to "' . $url . '" failed', 1364061673);
     }
     return $response;
 }
开发者ID:sschuberth,项目名称:Gerrie,代码行数:16,代码来源:HTTPDataService.php

示例6: parse

 /**
  * @param Response $curlResponse
  *
  * @throws HttpStatusParserException
  */
 public function parse(Response $curlResponse)
 {
     $statusCode = $curlResponse->getStatusCode();
     if ($this->shouldThrowException($statusCode)) {
         throw new HttpStatusParserException($curlResponse->getContent(), $statusCode);
     }
 }
开发者ID:krzysztof-gzocha,项目名称:payu,代码行数:12,代码来源:HttpStatusParser.php

示例7: rev

 public function rev(Response $response)
 {
     if ($response->isSuccessful()) {
         return $this->decode($response->getHeader('Etag'));
     }
     throw new RugException('not_found', 'The specified document or revision cannot be found or has been deleted');
 }
开发者ID:o100ja,项目名称:rug,代码行数:7,代码来源:AbstractDocumentParser.php

示例8: handleResponseAuthHeader

 /**
  * @param \Buzz\Message\Response $response
  */
 private function handleResponseAuthHeader(\Buzz\Message\Response $response)
 {
     $token = $response->getHeader('Update-Client-Auth');
     if ($token) {
         $this->client->setAuthToken($token);
         $this->setTokenToCache($token);
     }
 }
开发者ID:rgies,项目名称:dsp,代码行数:11,代码来源:ClientAuthManagerWrapper.php

示例9: send

 /**
  * @see Client\ClientInterface
  */
 public function send(Message\Request $request, Message\Response $response)
 {
     if (!($queued = $this->receiveFromQueue())) {
         throw new \LogicException('There are no queued responses.');
     }
     $response->setHeaders($queued->getHeaders());
     $response->setContent($queued->getContent());
 }
开发者ID:richardmiller,项目名称:Linktuesday.com,代码行数:11,代码来源:AbstractQueue.php

示例10: it_can_search_with__query

 public function it_can_search_with__query(Browser $client, Response $response)
 {
     $response->getContent()->shouldBeCalled();
     $client->get(sprintf('%s/search?%s', 'http://endpoint', http_build_query(['q' => 'pilkington avenue, birmingham', 'format' => 'json'])), ['User-Agent' => 'Nomatim PHP Library (https://github.com/nixilla/nominatim-consumer); email: not set'])->shouldBeCalled()->willReturn($response);
     $query = new Query();
     $query->setQuery('pilkington avenue, birmingham');
     $this->search($query)->shouldReturnAnInstanceOf('Nominatim\\Result\\Collection');
 }
开发者ID:nixilla,项目名称:nominatim-consumer,代码行数:8,代码来源:ConsumerSpec.php

示例11: testGetDomReturnsADomDocument

 public function testGetDomReturnsADomDocument()
 {
     $response = new Message\Response();
     $response->setContent('<html><head></head><body></body></html>');
     $this->browser->getClient()->sendToQueue($response);
     $this->browser->get('http://www.google.com');
     $this->assertTrue($this->browser->getDom() instanceof \DOMDocument);
 }
开发者ID:philip,项目名称:Buzz,代码行数:8,代码来源:BrowserTest.php

示例12: assertHttpResponseHasHeader

 protected function assertHttpResponseHasHeader(HttpResponse $response, $header, $expectedValue = null)
 {
     $headerValue = $response->getHeader($header);
     self::assertNotNull($headerValue, "Failed asserting that response has a {$header} header");
     if ($expectedValue !== null) {
         self::assertEquals($expectedValue, $headerValue);
     }
 }
开发者ID:Heyfara,项目名称:ezpublish-kernel,代码行数:8,代码来源:TestCase.php

示例13: _parse

 public function _parse(Response $response, $mime = null)
 {
     $data = $this->decode($response->getContent(), $mime);
     if (isset($data->error)) {
         throw new RugException($data->error, $this->_error($data));
     }
     return $data;
 }
开发者ID:o100ja,项目名称:rug,代码行数:8,代码来源:AbstractParser.php

示例14: processSetCookieHeaders

 /**
  * Processes Set-Cookie headers from a request/response pair.
  * 
  * @param Message\Request  $request  A request object
  * @param Message\Response $response A response object
  */
 public function processSetCookieHeaders(Message\Request $request, Message\Response $response)
 {
     foreach ($response->getHeader('Set-Cookie', false) as $header) {
         $cookie = new Cookie();
         $cookie->fromSetCookieHeader($header, parse_url($request->getHost(), PHP_URL_HOST));
         $this->addCookie($cookie);
     }
 }
开发者ID:philip,项目名称:Buzz,代码行数:14,代码来源:Jar.php

示例15: processResponse

 /**
  * @param  Response $response
  *
  * @return string
  */
 private function processResponse(Response $response)
 {
     $matches = [];
     preg_match('/<input.*value="(.*)"/U', $response->getContent(), $matches);
     if (!isset($matches[1])) {
         throw new \RuntimeException('Screenshot upload failed');
     }
     return $matches[1];
 }
开发者ID:stof,项目名称:behat-screenshot-image-driver-uploadpie,代码行数:14,代码来源:UploadPieApi.php


注:本文中的Buzz\Message\Response类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。