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


PHP Client::getLastRawRequest方法代码示例

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


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

示例1: testRawCookiesInRequestHeaders

 /**
  * Test sending cookie header with raw value
  *
  * @group fix-double-encoding-problem-about-cookie-value
  */
 public function testRawCookiesInRequestHeaders()
 {
     $this->_client->setConfig(array('encodecookies' => false));
     $this->_client->addCookie('foo', 'bar=baz');
     $this->_client->send();
     $cookieValue = 'Cookie: foo=bar=baz';
     $this->assertContains($cookieValue, $this->_client->getLastRawRequest(), 'Request is expected to contain the entire cookie "keyname=raw_value"');
 }
开发者ID:navtis,项目名称:xerxes-pazpar2,代码行数:13,代码来源:StaticTest.php

示例2: testUsesProvidedArgSeparator

 /**
  * @group 2774
  * @group 2745
  */
 public function testUsesProvidedArgSeparator()
 {
     $this->client->setArgSeparator(';');
     $request = new Request();
     $request->setUri('http://framework.zend.com');
     $request->setQuery(array('foo' => 'bar', 'baz' => 'bat'));
     $this->client->send($request);
     $rawRequest = $this->client->getLastRawRequest();
     $this->assertContains('?foo=bar;baz=bat', $rawRequest);
 }
开发者ID:benivaldo,项目名称:zf2-na-pratica,代码行数:14,代码来源:CommonHttpTests.php

示例3: profilerFinish

 /**
  * @param Client $target
  * @return $this
  */
 public function profilerFinish(Client $target)
 {
     $current =& $this->profiles[$this->currentIndex];
     $current['end'] = microtime(true);
     $current['elapse'] = $current['end'] - $current['start'];
     $current['request'] = (string) $target->getLastRawRequest();
     $current['response'] = (string) $target->getLastRawResponse();
     $this->currentIndex++;
     return $this;
 }
开发者ID:matryoshka-model,项目名称:service-api,代码行数:14,代码来源:Profiler.php

示例4: testContentTypeAdditionlInfo

 /**
  * @group ZF2-78
  * @dataProvider parameterArrayProvider
  */
 public function testContentTypeAdditionlInfo($params)
 {
     $content_type = 'application/x-www-form-urlencoded; charset=UTF-8';
     $this->client->setUri($this->baseuri . 'testPostData.php');
     $this->client->setHeaders(array('Content-Type' => $content_type));
     $this->client->setMethod(\Zend\Http\Request::METHOD_POST);
     $this->client->setParameterPost($params);
     $this->client->send();
     $request = Request::fromString($this->client->getLastRawRequest());
     $this->assertEquals($content_type, $request->getHeaders()->get('Content-Type')->getFieldValue());
 }
开发者ID:navassouza,项目名称:zf2,代码行数:15,代码来源:CommonHttpTests.php

示例5: testRawCookiesInRequestHeaders

 /**
  * Test sending cookie header with raw value
  *
  * @group fix-double-encoding-problem-about-cookie-value
  */
 public function testRawCookiesInRequestHeaders()
 {
     if (!constant('TESTS_ZEND_HTTP_CLIENT_ONLINE')) {
         $this->markTestSkipped('Zend\\Http\\Client online tests are not enabled');
     }
     $this->_client->setOptions(array('encodecookies' => false));
     $this->_client->addCookie('foo', 'bar=baz');
     $this->_client->send();
     $cookieValue = 'Cookie: foo=bar=baz';
     $this->assertContains($cookieValue, $this->_client->getLastRawRequest(), 'Request is expected to contain the entire cookie "keyname=raw_value"');
 }
开发者ID:rajanlamic,项目名称:IntTest,代码行数:16,代码来源:StaticTest.php

示例6: testMultibyteRawPostDataZF2098

 /**
  * Test that we properly calculate the content-length of multibyte-encoded
  * request body
  *
  * This may file in case that mbstring overloads the substr and strlen
  * functions, and the mbstring internal encoding is a multibyte encoding.
  *
  * @link http://framework.zend.com/issues/browse/ZF-2098
  */
 public function testMultibyteRawPostDataZF2098()
 {
     $this->_client->setAdapter('Zend\\Http\\Client\\Adapter\\Test');
     $this->_client->setUri('http://example.com');
     $bodyFile = __DIR__ . '/_files/ZF2098-multibytepostdata.txt';
     $this->_client->setRawBody(file_get_contents($bodyFile));
     $this->_client->setEncType('text/plain');
     $this->_client->setMethod('POST');
     $this->_client->send();
     $request = $this->_client->getLastRawRequest();
     if (!preg_match('/^content-length:\\s+(\\d+)/mi', $request, $match)) {
         $this->fail("Unable to find content-length header in request");
     }
     $this->assertEquals(filesize($bodyFile), (int) $match[1]);
 }
开发者ID:nevvermind,项目名称:zf2,代码行数:24,代码来源:StaticTest.php

示例7: testClientUsesAcceptEncodingHeaderFromRequestObject

    public function testClientUsesAcceptEncodingHeaderFromRequestObject()
    {
        $client = new Client();

        $client->setAdapter('Zend\Http\Client\Adapter\Test');

        $request = $client->getRequest();

        $acceptEncodingHeader = new AcceptEncoding();
        $acceptEncodingHeader->addEncoding('foo', 1);
        $request->getHeaders()->addHeader($acceptEncodingHeader);

        $client->send();

        $rawRequest = $client->getLastRawRequest();

        $this->assertNotContains('Accept-Encoding: gzip, deflate', $rawRequest, null, true);
        $this->assertNotContains('Accept-Encoding: identity', $rawRequest, null, true);

        $this->assertContains('Accept-Encoding: foo', $rawRequest);
    }
开发者ID:benivaldo,项目名称:zf2-na-pratica,代码行数:21,代码来源:ClientTest.php

示例8: testIfClientDoesNotForwardAuthenticationToForeignHost

 public function testIfClientDoesNotForwardAuthenticationToForeignHost()
 {
     // set up user credentials
     $user = 'username123';
     $password = 'password456';
     $encoded = Client::encodeAuthHeader($user, $password, Client::AUTH_BASIC);
     $testAdapter = new Test();
     $client = new Client(null, array('adapter' => $testAdapter));
     // set up two responses that simulate a redirection from example.org to example.com
     $testAdapter->setResponse("HTTP/1.1 303 See Other\r\n" . "Location: http://example.com/part2\r\n\r\n" . "The URL of this page has changed.");
     $testAdapter->addResponse("HTTP/1.1 200 OK\r\n\r\n" . "Welcome to this Website.");
     // set auth and do request
     $client->setUri('http://example.org/part1')->setAuth($user, $password, Client::AUTH_BASIC);
     $response = $client->setMethod('GET')->send();
     // the last request should NOT contain the Authorization header,
     // because example.com is different from example.org
     $this->assertTrue(strpos($client->getLastRawRequest(), $encoded) === false);
     // set up two responses that simulate a rediration from example.org to sub.example.org
     $testAdapter->setResponse("HTTP/1.1 303 See Other\r\n" . "Location: http://sub.example.org/part2\r\n\r\n" . "The URL of this page has changed.");
     $testAdapter->addResponse("HTTP/1.1 200 OK\r\n\r\n" . "Welcome to this Website.");
     // set auth and do request
     $client->setUri('http://example.org/part1')->setAuth($user, $password, Client::AUTH_BASIC);
     $response = $client->setMethod('GET')->send();
     // the last request should contain the Authorization header,
     // because sub.example.org is a subdomain unter example.org
     $this->assertFalse(strpos($client->getLastRawRequest(), $encoded) === false);
     // set up two responses that simulate a rediration from sub.example.org to example.org
     $testAdapter->setResponse("HTTP/1.1 303 See Other\r\n" . "Location: http://example.org/part2\r\n\r\n" . "The URL of this page has changed.");
     $testAdapter->addResponse("HTTP/1.1 200 OK\r\n\r\n" . "Welcome to this Website.");
     // set auth and do request
     $client->setUri('http://sub.example.org/part1')->setAuth($user, $password, Client::AUTH_BASIC);
     $response = $client->setMethod('GET')->send();
     // the last request should NOT contain the Authorization header,
     // because example.org is not a subdomain unter sub.example.org
     $this->assertTrue(strpos($client->getLastRawRequest(), $encoded) === false);
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:36,代码来源:ClientTest.php


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