Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send PHP cURL handles through a single TCP socket using HTTP Pipelining?

I'm trying to use PHP cURL HTTP Pipelining feature to perform multiple requests through single TCP connection. Refers to this page http://www.php.net/manual/en/function.curl-multi-setopt.php I'm enabling pipleining for curl_multi_exec() by adding:

curl_multi_setopt($mh, CURLMOPT_PIPELINING, 1);

I don't want to post a big source listing here, but you can easily view or checkout the full example from my github here https://github.com/anovikov1984/pipelining-example

For monitoring TCP connections I use 'netstat -t -u -c' command in another console session.

In my repo that I mentioned above there are two scripts. One for Ruby and one for PHP. The Ruby version works as wanted and opens only single TCP connection for 3 GET requests. But the PHP cURL version opens as many TCP connection as the number of cURL handles passed to curl_multi_exec() function.

What am i doing wrong?

like image 432
user3810306 Avatar asked Nov 01 '22 20:11

user3810306


1 Answers

It looks like this may be a bug in PHP's implementation of curl_multi_* with PIPELINING. It appears they may not expose all the CONSTANTS necessary to enable a developer to dictate how curl behaves on a multi-request when using PIPELINING.

I've submitted the bug report here: https://bugs.php.net/bug.php?id=68449

like image 145
datashovel Avatar answered Nov 09 '22 11:11

datashovel