本文整理汇总了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"');
}
示例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);
}
示例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;
}
示例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());
}
示例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"');
}
示例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]);
}
示例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);
}
示例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);
}