本文整理汇总了PHP中Goutte\Client::setServerParameter方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::setServerParameter方法的具体用法?PHP Client::setServerParameter怎么用?PHP Client::setServerParameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Goutte\Client
的用法示例。
在下文中一共展示了Client::setServerParameter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getWebClient
/**
* @return GoutteClient
*/
protected function getWebClient()
{
if (!$this->client) {
$this->client = new GoutteClient();
$this->client->setServerParameter('HTTP_USER_AGENT', 'Crawler');
}
return $this->client;
}
示例2: createClient
/**
* @return Client
*/
public function createClient()
{
$client = new Client();
$client->setServerParameter('HTTP_HOST', $this->host);
return $client;
}
示例3: testPostMultipartFormWithoutFiles
public function testPostMultipartFormWithoutFiles()
{
$guzzle = $this->getGuzzle();
$client = new Client();
$client->setClient($guzzle);
$params = array('foo' => 'bar');
$client->setServerParameter('Content-Type', 'multipart/form-data');
$client->request('POST', 'http://www.example.com/', $params);
/*
* @var Request
*/
$request = end($this->history)['request'];
$stream = $request->getBody();
$boundary = $stream->getBoundary();
$this->assertEquals("--{$boundary}\r\nContent-Disposition: form-data; name=\"foo\"\r\nContent-Length: 3\r\n" . "\r\nbar\r\n" . "--{$boundary}--\r\n", $stream->getContents());
}
示例4: getBrowser
/**
* Used internally to create/get the HTTP client
*
* @return Goutte\Client
*/
private function getBrowser()
{
if (!$this->browser instanceof Client) {
$browser = new Client();
$browser->setServerParameter('HTTP_USER_AGENT', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)');
$this->browser = $browser;
}
return $this->browser;
}