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


PHP Request::getResponse方法代码示例

本文整理汇总了PHP中Guzzle\Http\Message\Request::getResponse方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getResponse方法的具体用法?PHP Request::getResponse怎么用?PHP Request::getResponse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Guzzle\Http\Message\Request的用法示例。


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

示例1: testSetManualResponse

 public function testSetManualResponse()
 {
     $response = new Response(200, array('Date' => 'Sat, 16 Oct 2010 17:27:14 GMT', 'Expires' => '-1', 'Cache-Control' => 'private, max-age=0', 'Content-Type' => 'text/html; charset=ISO-8859-1'), 'response body');
     $this->assertSame($this->request, $this->request->setResponse($response), '-> setResponse() must use a fluent interface');
     $this->assertEquals('complete', $this->request->getState(), '-> setResponse() must change the state of the request to complete');
     $this->assertSame($response, $this->request->getResponse(), '-> setResponse() must set the exact same response that was passed in to it');
 }
开发者ID:jorjoh,项目名称:Varden,代码行数:7,代码来源:RequestTest.php

示例2: sendRequest

 public function sendRequest()
 {
     $client = new Client();
     // make a request object
     $request = $client->createRequest($this->requestType, $this->host . $this->resource);
     // set headers
     foreach ($this->headers as $header => $value) {
         $request->setHeader($header, $value);
     }
     // set body
     if (!empty($this->body)) {
         $request->setBody($this->body);
     }
     $this->request = $request;
     try {
         // finally send the request
         $this->response = $request->send();
     } catch (\Exception $e) {
         $this->response = $this->request->getResponse();
     }
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:21,代码来源:GuzzleClient.php

示例3: send

 /**
  * Send the request
  */
 public function send()
 {
     // make a request object
     $this->request = $this->client->createRequest($this->method, $this->host . $this->resource);
     // set headers
     foreach ($this->headers as $header => $value) {
         $this->request->setHeader($header, $value);
     }
     // set body
     if (!empty($this->body)) {
         $this->request->setBody($this->body);
     }
     try {
         // finally send the request
         $this->response = $this->client->send($this->request);
     } catch (BadResponseException $e) {
         $this->response = $this->request->getResponse();
     }
     $this->sent = true;
 }
开发者ID:CG77,项目名称:ezpublish-kernel,代码行数:23,代码来源:GuzzleDriver.php

示例4: getRawResponse

 /**
  * 
  * @return \Guzzle\Http\Message\Response
  */
 public function getRawResponse()
 {
     return $this->_request->getResponse();
 }
开发者ID:sokil,项目名称:php-rest,代码行数:8,代码来源:Request.php

示例5: processSuccessfulRequest

 /**
  * @param Request $request
  * @param string  $body
  */
 private function processSuccessfulRequest(Request $request, $body)
 {
     $response = $request->getResponse();
     $headers = $request->getHeaders()->getAll();
     $responseBody = $response->getBody(true);
     $status = $response->getStatusCode();
     $this->lastRequest['response']['body'] = $responseBody;
     $this->lastRequest['response']['status'] = $status;
     $this->logRequestSuccess($request->getMethod(), $request->getUrl(), $body, $headers, $status, $responseBody, $response->getInfo('total_time'));
 }
开发者ID:security-geeks,项目名称:squert,代码行数:14,代码来源:GuzzleConnection.php

示例6: testReceivingShortStatusLineResponse

 /**
  * Many RESTful frameworks omit the text status from the header. That
  * provides a response like "HTTP/1.1 200". Prevent an Undefined offset
  * by checking to see how many parts of the status line are provided
  * before trying to assign them.
  *
  * @covers Guzzle\Http\Message\Request::receiveResponseHeader
  */
 public function testReceivingShortStatusLineResponse()
 {
     $request = new Request('GET', $this->getServer()->getUrl());
     $request->receiveResponseHeader('HTTP/1.1 200');
     $this->assertSame(200, $request->getResponse()->getStatusCode());
     $this->assertSame('OK', $request->getResponse()->getReasonPhrase());
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:15,代码来源:RequestTest.php

示例7: testReceivingUnsuccessfulResponseUsesOtherResponseBody

 /**
  * Users sometimes want to use a custom stream when receiving a response body.
  * Because of the various potential for retrying failed requests, the stream
  * specified by the user should only be written to in the event that a
  * successful response was received.  Otherwise, a new temp stream is created
  * to store the body of the failed request.
  *
  * @covers Guzzle\Http\Message\Request::receiveResponseHeader
  */
 public function testReceivingUnsuccessfulResponseUsesOtherResponseBody()
 {
     $request = new Request('GET', $this->getServer()->getUrl());
     $body = EntityBody::factory();
     $request->setResponseBody($body);
     $request->receiveResponseHeader('HTTP/1.1 503 Service Unavailable');
     $this->assertNotSame($body, $request->getResponse()->getBody());
 }
开发者ID:nickpeirson,项目名称:guzzle,代码行数:17,代码来源:RequestTest.php

示例8: testDoesNotInjectUnsatisfiableResponsesOnException

 /**
  * @dataProvider unsatisfiableOnErrorProvider
  */
 public function testDoesNotInjectUnsatisfiableResponsesOnException($requestCanCache, $requestHeaders, $responseParts)
 {
     $storage = $this->getMockBuilder('Guzzle\\Plugin\\Cache\\CacheStorageInterface')->setMethods(array('fetch'))->getMockForAbstractClass();
     $storage->expects($this->exactly($requestCanCache ? 2 : 0))->method('fetch')->will($this->returnValue($responseParts));
     $plugin = new CachePlugin(array('storage' => $storage));
     $request = new Request('GET', 'http://foo.com', $requestHeaders);
     $plugin->onRequestBeforeSend(new Event(array('request' => $request)));
     $plugin->onRequestException($event = new Event(array('request' => $request, 'response' => $response = $request->getResponse(), 'exception' => $this->getMock('Guzzle\\Http\\Exception\\CurlException'))));
     $this->assertSame($response, $request->getResponse());
 }
开发者ID:rahilmomin,项目名称:ci_bootstrap_3,代码行数:13,代码来源:CachePluginTest.php

示例9: testInjectsSatisfiableResponses

 public function testInjectsSatisfiableResponses()
 {
     $storage = $this->getMockBuilder('Guzzle\\Plugin\\Cache\\CacheStorageInterface')->setMethods(array('fetch'))->getMockForAbstractClass();
     $storage->expects($this->once())->method('fetch')->will($this->returnValue(array(200, array(), 'foo')));
     $plugin = new CachePlugin(array('storage' => $storage));
     $request = new Request('GET', 'http://foo.com');
     $plugin->onRequestBeforeSend(new Event(array('request' => $request)));
     $this->assertEquals(200, $request->getResponse()->getStatusCode());
     $this->assertEquals('foo', $request->getResponse()->getBody(true));
     $this->assertContains('key=', (string) $request->getResponse()->getHeader('X-Guzzle-Cache'));
     $this->assertTrue($request->getResponse()->hasHeader('Age'));
 }
开发者ID:KANU82,项目名称:guzzle,代码行数:12,代码来源:CachePluginTest.php


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