svn: /pear/packages/HTTP_Request2/trunk/ HTTP/Request2/Response.php HTTP/Request2.php tests/Request2Test.php
| From: | Alexey Borzov | Date: | Sat, 07 Apr 2012 07:49:03 +0000 |
| Subject: | svn: /pear/packages/HTTP_Request2/trunk/ HTTP/Request2/Response.php HTTP/Request2.php tests/Request2Test.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-64650@lists.php.net to get a copy of this message | ||
avb Sat, 07 Apr 2012 07:49:03 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=324936
Log:
Use '8bit' for mb_internal_encoding(), that's supposedly faster
It is now possible to give proxy as an URL, e.g. setConfig('proxy',
'socks5://localhost:1080')
Changed paths:
U pear/packages/HTTP_Request2/trunk/HTTP/Request2/Response.php
U pear/packages/HTTP_Request2/trunk/HTTP/Request2.php
U pear/packages/HTTP_Request2/trunk/tests/Request2Test.php
Modified: pear/packages/HTTP_Request2/trunk/HTTP/Request2/Response.php
===================================================================
--- pear/packages/HTTP_Request2/trunk/HTTP/Request2/Response.php 2012-04-07 07:10:50 UTC (rev
324935)
+++ pear/packages/HTTP_Request2/trunk/HTTP/Request2/Response.php 2012-04-07 07:49:03 UTC (rev
324936)
@@ -453,7 +453,7 @@
} else {
if (extension_loaded('mbstring') && (2 &
ini_get('mbstring.func_overload'))) {
$oldEncoding = mb_internal_encoding();
- mb_internal_encoding('iso-8859-1');
+ mb_internal_encoding('8bit');
}
try {
Modified: pear/packages/HTTP_Request2/trunk/HTTP/Request2.php
===================================================================
--- pear/packages/HTTP_Request2/trunk/HTTP/Request2.php 2012-04-07 07:10:50 UTC (rev 324935)
+++ pear/packages/HTTP_Request2/trunk/HTTP/Request2.php 2012-04-07 07:49:03 UTC (rev 324936)
@@ -344,6 +344,8 @@
* <li> 'proxy_user' - Proxy auth username (string)</li>
* <li> 'proxy_password' - Proxy auth password (string)</li>
* <li> 'proxy_auth_scheme' - Proxy auth scheme, one of HTTP_Request2::AUTH_*
constants (string)</li>
+ * <li> 'proxy' - Shorthand for proxy_* parameters, proxy given
as URL,
+ * e.g. 'socks5://localhost:1080/' (string)</li>
* <li> 'ssl_verify_peer' - Whether to verify peer's SSL certificate
(bool)</li>
* <li> 'ssl_verify_host' - Whether to check that Common Name in SSL
* certificate matches host name (bool)</li>
@@ -379,6 +381,16 @@
$this->setConfig($name, $value);
}
+ } elseif ('proxy' == $nameOrConfig) {
+ $url = new Net_URL2($value);
+ $this->setConfig(array(
+ 'proxy_type' => $url->getScheme(),
+ 'proxy_host' => $url->getHost(),
+ 'proxy_port' => $url->getPort(),
+ 'proxy_user' => rawurldecode($url->getUser()),
+ 'proxy_password' => rawurldecode($url->getPassword())
+ ));
+
} else {
if (!array_key_exists($nameOrConfig, $this->config)) {
throw new HTTP_Request2_LogicException(
@@ -940,7 +952,7 @@
// strlen() and substr(); see bug #1781, bug #10605
if (extension_loaded('mbstring') && (2 &
ini_get('mbstring.func_overload'))) {
$oldEncoding = mb_internal_encoding();
- mb_internal_encoding('iso-8859-1');
+ mb_internal_encoding('8bit');
}
try {
Modified: pear/packages/HTTP_Request2/trunk/tests/Request2Test.php
===================================================================
--- pear/packages/HTTP_Request2/trunk/tests/Request2Test.php 2012-04-07 07:10:50 UTC (rev 324935)
+++ pear/packages/HTTP_Request2/trunk/tests/Request2Test.php 2012-04-07 07:49:03 UTC (rev 324936)
@@ -129,6 +129,18 @@
} catch (HTTP_Request2_LogicException $e) {}
}
+ public function testSetProxyAsUrl()
+ {
+ $req = new HTTP_Request2();
+ $req->setConfig('proxy', 'socks5://foo:bar%25baz@localhost:1080/');
+
+ $this->assertEquals('socks5', $req->getConfig('proxy_type'));
+ $this->assertEquals('localhost', $req->getConfig('proxy_host'));
+ $this->assertEquals(1080, $req->getConfig('proxy_port'));
+ $this->assertEquals('foo', $req->getConfig('proxy_user'));
+ $this->assertEquals('bar%baz',
$req->getConfig('proxy_password'));
+ }
+
/**
*
* @expectedException HTTP_Request2_LogicException