Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixed proxy adapter keys being incorrectly set due Zend\Http\Client #2907

Closed
wants to merge 1 commit into from

2 participants

Brian Gallagher Matthew Weier O'Phinney
Brian Gallagher

repo: git://github.com/bgallagher/zf2.git
branch: ProxyClientAdapterBugFix

Zend\Http\Client::setOptions normalises the option keys, removing underscores among other things. However Zend\Http\Client\Adapter\Proxy expects keys proxy_host & proxy_port set including the underscores. This patch adds the method Zend\Http\Client\Adapter\Proxy::setOptions which correctly sets the keys.

Deleted user Unknown referenced this pull request from a commit
Matthew Weier O'Phinney weierophinney Merge branch 'hotfix/2907'
Close #2907
82c0eb7
Deleted user Unknown referenced this pull request from a commit
Matthew Weier O'Phinney weierophinney Merge branch 'hotfix/2907' into develop
Forward port #2907
f31f0c9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
18 library/Zend/Http/Client/Adapter/Proxy.php
View
@@ -59,6 +59,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
*
* Will try to connect to the proxy server. If no proxy was set, will
23 tests/ZendTest/Http/Client/ProxyAdapterTest.php
View
@@ -28,6 +28,11 @@
*/
class ProxyAdapterTest extends SocketTest
{
+
+
+ protected $host;
+ protected $port;
+
/**
* Configuration array
*
@@ -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;
@@ -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') &&
@@ -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);
+ }
+
}
Something went wrong with that request. Please try again.