本文整理汇总了PHP中Zend\Http\Client::setConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::setConfig方法的具体用法?PHP Client::setConfig怎么用?PHP Client::setConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Http\Client
的用法示例。
在下文中一共展示了Client::setConfig方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: enableRequestDebugLogging
/**
* This method enables logging of requests by changing the
* Zend_Http_Client_Adapter used for performing the requests.
* NOTE: This will not work if you have customized the adapter
* already to use a proxy server or other interface.
*
* @param $logfile The logfile to use when logging the requests
*/
public function enableRequestDebugLogging($logfile)
{
$this->_httpClient->setConfig(array(
'adapter' => 'Zend\GData\App\LoggingHttpClientAdapterSocket',
'logfile' => $logfile
));
}
示例2: 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"');
}
示例3: setUp
/**
*
* @return void
*/
public function setUp()
{
if (!constant('TESTS_ZEND_SERVICE_DELICIOUS_ENABLED')) {
$this->markTestSkipped('\\Zend\\Service\\Delicious online tests are not enabled');
}
$httpClient = new Http\Client();
$httpClient->setConfig(array('useragent' => 'Zend\\Service\\Delicious - Unit tests/0.1', 'keepalive' => true));
RestClient\RestClient::setDefaultHttpClient($httpClient);
$this->_delicious = new Delicious\Delicious(self::TEST_UNAME, self::TEST_PASS);
}
示例4: testSocketErrorException
/**
* Check we get an exception if there's an error in the socket
*
*/
public function testSocketErrorException()
{
$this->setExpectedException('Zend\\Http\\Client\\Adapter\\Exception\\RuntimeException', 'Unable to Connect to tcp://255.255.255.255:80');
// Try to connect to an invalid host
$this->_client->setUri('http://255.255.255.255');
// Reduce timeout to 3 seconds to avoid waiting
$this->_client->setConfig(array('timeout' => 3));
// This call should cause an exception
$this->_client->send();
}
示例5: testRelativePathRedirect
/**
* Test we can properly redirect to a relative path
*
*/
public function testRelativePathRedirect()
{
$this->client->setUri($this->baseuri . 'testRelativeRedirections.php');
$this->client->setParameterGet(array('redirect' => 'relpath'));
$this->client->setConfig(array('maxredirects' => 1));
// Set the new expected URI
$uri = clone $this->client->getUri();
$uri->setPath(rtrim(dirname($uri->getPath()), '/') . '/path/to/fake/file.ext');
$uri = $uri->__toString();
$res = $this->client->send();
$this->assertEquals("{$uri}?redirect=relpath", $this->client->getUri()->toString(), "The new location is not as expected: {$this->client->getUri()->toString()}");
}
示例6: getHttpClient
/**
* Returns the instance of the Zend\Http\Client which will be used. Creates an instance
* of Zend\Http\Client if no previous client was set.
*
* @return Zend\Http\Client The HTTP client which will be used
*/
public function getHttpClient()
{
if (!$this->httpclient instanceof Http\Client) {
$client = new Http\Client();
$client->setConfig(array('maxredirects' => 2, 'timeout' => 5));
$this->setHttpClient($client);
}
$this->httpclient->resetParameters();
return $this->httpclient;
}
示例7: fetchHoldings
/**
* Fetch item and holding records from an ILS for this record
*/
public function fetchHoldings()
{
$xerxes_record = $this->getXerxesRecord();
$id = $xerxes_record->getRecordID();
// id from the record
$cache_id = $xerxes_record->getSource() . "." . $id;
// to identify this in the cache
$url = $this->config->getConfig("LOOKUP");
// url to availability server
// mark that we've checked holdings either way
$this->holdings->checked = true;
// no holdings source defined or somehow id's are blank
if ($xerxes_record->hasPhysicalHoldings() == false || $url == "" || $id == "") {
return null;
}
// get the data
$url .= "?action=status&id=" . urlencode($id);
// @todo this needs to be gotten from a factory or something
$client = new Client();
$client->setUri($url);
$client->setConfig(array('timeout' => 5));
$data = $client->send()->getBody();
// echo $url; exit;
// no data, what's up with that?
if ($data == "") {
throw new \Exception("could not connect to availability server");
}
// response is (currently) an array of json objects
$results = json_decode($data);
// parse the response
if (is_array($results)) {
if (count($results) > 0) {
// now just slot them into our item object
foreach ($results as $holding) {
$is_holding = property_exists($holding, "holding");
if ($is_holding == true) {
$item = new Holding();
$this->holdings->addHolding($item);
} else {
$item = new Item();
$this->holdings->addItem($item);
}
foreach ($holding as $property => $value) {
$item->setProperty($property, $value);
}
}
}
}
// cache it for the future
// @todo: zend\cache
$cache = new Cache();
$expiry = $this->config->getConfig("HOLDINGS_CACHE_EXPIRY", false, 2 * 60 * 60);
// expiry set for two hours
$expiry += time();
$cache->set($cache_id, serialize($this->holdings), $expiry);
return null;
}