cURL / Mailing Lists / curl-library / Single Mail

curl-library

HTTP pipelining question

From: Dmitry Kurochkin <dmitry.kurochkin_at_gmail.com>
Date: Mon, 24 Dec 2007 04:03:23 +0300

Hello.

I have a question about HTTP pipelining.
I need to download many files from one server. I have a sample program
which creates a multi handle, sets pipeline option, then creates and
adds to multi handle a number of easy handles and loops with
curl_multi_perform().
All easy handles have same URL. I expect libcurl to use only a single
connection to the server and pipeline requests. But each request
creates a separate connection. Here is verbose output:

* About to connect() to ya.ru port 80 (#0)
* Trying 213.180.204.8... * Connection #0 isn't open enough, can't reuse
* About to connect() to ya.ru port 80 (#1)
* Trying 213.180.204.8... * Connection #0 isn't open enough, can't reuse
* Connection #1 isn't open enough, can't reuse
* About to connect() to ya.ru port 80 (#2)
* Trying 213.180.204.8... * Connection #0 isn't open enough, can't reuse
.....

After looking at source code this looks like intended behavior. Here
is a comment from ConnectionExists function:

      /* Don't pick a connection that hasn't connected yet or that is going to
         get closed. */

I do not understand this. Why does not libcurl detect that there is
another connection being made to the server and reuses it? I guess it
would work if I wait for the first connection to complete before the
second easy handle is added. But what I really want is libcurl to do
this scheduling for me.

Is this possible? Maybe I can limit number of connections to a single
host somehow?
This looks like a common problem to me. So there should be some
solution I guess...

Regards,
  Dmitry
Received on 2007-12-24