Bug #74135 [NEW]: CURLOPT_RESOLVE don't work properly in second time curl call
| From: | icez at icez dot net | Date: | Mon, 20 Feb 2017 16:10:49 +0000 |
| Subject: | Bug #74135 [NEW]: CURLOPT_RESOLVE don't work properly in second time curl call | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-207470@lists.php.net to get a copy of this message | ||
From: icez at icez dot net
Operating system: Linux Debian Jessie
PHP version: 7.0.16
Package: cURL related
Bug Type: Bug
Bug description:CURLOPT_RESOLVE don't work properly in second time curl call
Description:
------------
I have the code that call several servers behind the load balancer to
check for the page load result. The server was configured with SSL so I
need the way to force curl to connect to specific IP address with the
correct hostname without having to set SSL_VERIFYHOST to false and found
curl option CURLOPT_RESOLVE. I've tested that curl command line can use
this option to force connect to specific server IP address, but when I
run the test script in PHP it always connect to first server. which is
the first address to have this option set to.
related question:
http://stackoverflow.com/questions/36434049/php-curl-curlopt-resolve-not-working
Test script:
---------------
$servers = [ '192.0.2.1', '192.0.2.2', '192.0.2.3' ];
foreach ($servers as $server) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_DNS_CACHE_TIMEOUT, 0);
curl_setopt($ch, CURLOPT_RESOLVE, $resolveparam);
curl_setopt($ch, CURLOPT_URL, "https://example.com/some/path");
curl_setopt($ch, CURLOPT_VERBOSE, 1);
$result = curl_exec($ch);
$info = curl_getinfo($ch);
echo $info['primary_ip']."\n";
curl_close($ch);
}
Expected result:
----------------
192.0.2.1
192.0.2.2
192.0.2.3
Actual result:
--------------
192.0.2.1
192.0.2.1
192.0.2.1
--
Edit bug report at https://bugs.php.net/bug.php?id=74135&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74135&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74135&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74135&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=74135&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=74135&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=74135&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=74135&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=74135&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=74135&r=support
Expected behavior: https://bugs.php.net/fix.php?id=74135&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=74135&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=74135&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=74135&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74135&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=74135&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=74135&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=74135&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=74135&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=74135&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=74135&r=mysqlcfg