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


PHP Response::getEffectiveUrl方法代码示例

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


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

示例1: testHasEffectiveUrl

 public function testHasEffectiveUrl()
 {
     $r = new Response(200);
     $this->assertNull($r->getEffectiveUrl());
     $r->setEffectiveUrl('http://www.test.com');
     $this->assertEquals('http://www.test.com', $r->getEffectiveUrl());
 }
开发者ID:neelie,项目名称:respond,代码行数:7,代码来源:ResponseTest.php

示例2: setUpBeforeClass

 /**
  * Set up our test fixture.
  *
  * Expect a service URL something like this:
  *   http://api.nfldata.apiphany.com/developer/xml/AreAnyGamesInProgress/?key=000aaaa0-a00a-0000-0a0a-aa0a00000000
  */
 public static function setUpBeforeClass()
 {
     static::$sClient = new MockClient($_SERVER['FANTASY_DATA_API_KEY'], Subscription::KEY_DEVELOPER);
     /** \GuzzleHttp\Command\Model */
     static::$sClient->AreAnyGamesInProgress([]);
     static::$sResponse = static::$sClient->mHistory->getLastResponse();
     static::$sEffectiveUrl = static::$sResponse->getEffectiveUrl();
     static::$sUrlFragments = explode('/', static::$sEffectiveUrl);
 }
开发者ID:JJVV27,项目名称:FantasyDataAPI,代码行数:15,代码来源:UnitTest.php

示例3: __construct

 /**
  * Constructor
  *
  * @param GuzzleResponse $response
  */
 public function __construct(GuzzleResponse $response)
 {
     $headers = $response->getHeaders();
     //-- this is a hack on my part and I'm terribly sorry it exists
     //-- but deal with it.
     foreach ($headers as $header => $value) {
         $this->headers[$header] = implode(',', array_values((array) $value));
     }
     $this->url = $response->getEffectiveUrl();
     $url_parts = explode('?', $this->url);
     if (isset($url_parts[1])) {
         $query = explode('&', $url_parts[1]);
         foreach ($query as $params) {
             $kv = explode('=', $params);
             $this->params[$kv[0]] = isset($kv[1]) ? $kv[1] : '';
         }
     }
     // $this->params = $response->request_parameters;
     // $this->method = $response->request_method;
     $this->json = $response->json();
     // $json = json_decode($this->json, TRUE);
     $this->data = isset($this->json['data']) ? $this->json['data'] : [];
     $this->meta = isset($this->json['meta']) ? $this->json['meta'] : [];
     if (isset($this->json['code']) && $this->json['code'] !== 200) {
         $this->meta = $this->json;
     }
     $this->pagination = isset($this->json['pagination']) ? $this->json['pagination'] : [];
     $this->user = isset($this->json['user']) ? $this->json['user'] : [];
     $this->access_token = isset($this->json['access_token']) ? $this->json['access_token'] : NULL;
     $this->limit = isset($this->headers[self::RATE_LIMIT_HEADER]) ? $this->headers[self::RATE_LIMIT_HEADER] : 0;
     $this->remaining = isset($this->headers[self::RATE_LIMIT_REMAINING_HEADER]) ? $this->headers[self::RATE_LIMIT_REMAINING_HEADER] : 0;
 }
开发者ID:delta98,项目名称:Instaphp,代码行数:37,代码来源:Response.php

示例4: debug

 function debug(\GuzzleHttp\Message\Response $response)
 {
     $this->dump_respuesta = 'status: ' . $response->getStatusCode() . "<br/>body: <br/>" . $response->getBody();
     //un string encodeado utf-8
     $this->dump_url = $response->getEffectiveUrl();
     //un string encodeado utf-8
 }
开发者ID:emma5021,项目名称:toba,代码行数:7,代码来源:ci_cliente_rest.php

示例5: testDoesTheSameAsResponseWhenDereferenced

 public function testDoesTheSameAsResponseWhenDereferenced()
 {
     $str = Stream::factory('foo');
     $response = new Response(200, ['Foo' => 'bar'], $str);
     $future = MockTest::createFuture(function () use($response) {
         return $response;
     });
     $this->assertFalse($this->readAttribute($future, 'isRealized'));
     $this->assertEquals(200, $future->getStatusCode());
     $this->assertTrue($this->readAttribute($future, 'isRealized'));
     // Deref again does nothing.
     $future->wait();
     $this->assertTrue($this->readAttribute($future, 'isRealized'));
     $this->assertEquals('bar', $future->getHeader('Foo'));
     $this->assertEquals(['bar'], $future->getHeaderAsarray('Foo'));
     $this->assertSame($response->getHeaders(), $future->getHeaders());
     $this->assertSame($response->getBody(), $future->getBody());
     $this->assertSame($response->getProtocolVersion(), $future->getProtocolVersion());
     $this->assertSame($response->getEffectiveUrl(), $future->getEffectiveUrl());
     $future->setEffectiveUrl('foo');
     $this->assertEquals('foo', $response->getEffectiveUrl());
     $this->assertSame($response->getReasonPhrase(), $future->getReasonPhrase());
     $this->assertTrue($future->hasHeader('foo'));
     $future->removeHeader('Foo');
     $this->assertFalse($future->hasHeader('foo'));
     $this->assertFalse($response->hasHeader('foo'));
     $future->setBody(Stream::factory('true'));
     $this->assertEquals('true', (string) $response->getBody());
     $this->assertTrue($future->json());
     $this->assertSame((string) $response, (string) $future);
     $future->setBody(Stream::factory('<a><b>c</b></a>'));
     $this->assertEquals('c', (string) $future->xml()->b);
     $future->addHeader('a', 'b');
     $this->assertEquals('b', $future->getHeader('a'));
     $future->addHeaders(['a' => '2']);
     $this->assertEquals('b, 2', $future->getHeader('a'));
     $future->setHeader('a', '2');
     $this->assertEquals('2', $future->getHeader('a'));
     $future->setHeaders(['a' => '3']);
     $this->assertEquals(['a' => ['3']], $future->getHeaders());
 }
开发者ID:hexcode007,项目名称:yfcms,代码行数:41,代码来源:FutureResponseTest.php

示例6: fromResponse

    /**
     * @param \GuzzleHttp\Message\Response $response
     *
     * @throws DocumentBuilderException
     * @return \Morphodo\CrawlerBundle\Domain\Document
     */
    public function fromResponse(\GuzzleHttp\Message\Response $response)
    {
        $this->response = $response;
        $document = new IndexerBundle\Domain\Document();
        if ($this->detectEncoding() != 'UTF-8') {
            $convertedBody = @iconv($this->detectEncoding(), $this->defaultEncoding . "//TRANSLIT", (string) $this->response->getBody());
            if ($convertedBody === FALSE) {
                throw new Domain\DocumentBuilderException('Document charset conversion from ' . $this->detectEncoding() . '
				 into ' . $this->defaultEncoding . ' failed for document: ' . $this->response->getEffectiveUrl(), 1420557940);
            }
            $convertedBody = $this->updateContentTypeStringWithinMetaTag($this->convertEntitiesIntoUtf8($convertedBody));
        }
        $document->setContent($convertedBody);
        $document->setUrl($response->getEffectiveUrl());
        return $document;
    }
开发者ID:morphodo,项目名称:crawler-bundle,代码行数:22,代码来源:DocumentBuilder.php

示例7: publishRequest

 /**
  * Announces HTTP request to Wildfire channel
  *
  * @param GuzzleHttp\Message\Request
  * @param GuzzleHttp\Message\Response   when dealing with error events, response may not be populated
  * @param float $elapsed
  */
 public function publishRequest(Request $request, Response $response = null, $elapsed = 0)
 {
     $request_body = $request->getBody();
     $request_preview = '';
     if ($request_body) {
         $request_body->seek(0);
         // rewind the cursor in case a read was already done
         $request_preview = $request_body->read($this->_preview_length);
         $request_body->seek(0);
         // rewind the cursor, so subsequent reads are not affected
     }
     // Ensure response is populated before extracting body from it
     $response_body = $response ? $response->getBody() : '';
     $response_preview = '';
     if ($response_body) {
         $response_body->seek(0);
         // rewind the cursor, in case a read was already done
         $response_preview = $response_body->read($this->_preview_length);
         $response_body->seek(0);
         // rewind the cursor, so subsequent reads are not affected
     }
     $phrase = $response ? $response->getReasonPhrase() : self::ERROR_NO_RESPONSE;
     $table = [];
     $table[] = ['Key', 'Value'];
     $table[] = ['Phrase', $phrase];
     $table[] = ['Host', $request->getHost()];
     $table[] = ['Protocol', $request->getScheme()];
     $table[] = ['User Agent', $request->getHeader('User-Agent')];
     $table[] = ['Request', $request_preview];
     $table[] = ['Response', $response_preview];
     if ($response && $response->getEffectiveUrl() != $request->getUrl()) {
         $table[] = ['Effective URL', $response->getEffectiveUrl()];
     }
     $elapsed = number_format($elapsed, 4);
     $status = $response ? $response->getStatusCode() : 0;
     $message = sprintf("%s <%s> (%d) %s (%f)s", $this->_remote_prefix, $request->getMethod(), $status, $request->getUrl(), $elapsed);
     $this->_client->table($message, $table);
 }
开发者ID:behance,项目名称:guzzle-fireclient,代码行数:45,代码来源:ResponseConsumer.php

示例8: getRequestedURL

 /**
  * get request url
  * @return string
  */
 public function getRequestedURL()
 {
     return $this->response->getEffectiveUrl();
 }
开发者ID:nasrulhazim,项目名称:Laravel5-billplz,代码行数:8,代码来源:TransportResponse.php


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