Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/2907' into develop
Browse files Browse the repository at this point in the history
Forward port #2907
  • Loading branch information
weierophinney committed Nov 16, 2012
2 parents 3dac975 + 97ad8bf commit f31f0c9
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
18 changes: 18 additions & 0 deletions library/Zend/Http/Client/Adapter/Proxy.php
Expand Up @@ -58,6 +58,24 @@ class Proxy extends Socket
*/
protected $negotiated = false;

/**
* Set the configuration array for the adapter
*
* @param array $options
*/
public function setOptions($options = array())
{
//enforcing that the proxy keys are set in the form proxy_*
foreach ($options as $k => $v) {
if (preg_match("/^proxy[a-z]+/", $k)) {
$options['proxy_' . substr($k, 5, strlen($k))] = $v;
unset($options[$k]);
}
}

parent::setOptions($options);
}

/**
* Connect to the remote server
*
Expand Down
23 changes: 23 additions & 0 deletions tests/ZendTest/Http/Client/ProxyAdapterTest.php
Expand Up @@ -28,6 +28,11 @@
*/
class ProxyAdapterTest extends SocketTest
{


protected $host;
protected $port;

/**
* Configuration array
*
Expand All @@ -43,6 +48,8 @@ protected function setUp()
if (! $host)
$this->markTestSkipped('No valid proxy host name or address specified.');

$this->host = $host;

$port = (int) $port;
if ($port == 0) {
$port = 8080;
Expand All @@ -51,6 +58,8 @@ protected function setUp()
$this->markTestSkipped("$port is not a valid proxy port number. Should be between 1 and 65535.");
}

$this->port = $port;

$user = '';
$pass = '';
if (defined('TESTS_ZEND_HTTP_CLIENT_HTTP_PROXY_USER') &&
Expand Down Expand Up @@ -110,4 +119,18 @@ public function testDefaultConfig()
$this->assertEquals(TRUE, $config['sslverifypeer']);
$this->assertEquals(FALSE, $config['sslallowselfsigned']);
}

/**
* Test that the proxy keys normalised by the client are correctly converted to what the proxy adapter expects.
*/
public function testProxyKeysCorrectlySetInProxyAdapter()
{
$adapterConfig = $this->_adapter->getConfig();
$adapterHost = $adapterConfig['proxy_host'];
$adapterPort = $adapterConfig['proxy_port'];

$this->assertSame($this->host, $adapterHost);
$this->assertSame($this->port, $adapterPort);
}

}

0 comments on commit f31f0c9

Please sign in to comment.