1

Let's say you have this

curl_easy_setopt(pCurl, CURLOPT_URL, url);
curl_multi_add_handle(pCurlMulti, pCurl);
curl_multi_perform(...)

// now we are waiting for response from the server // while waiting, could we call

curl_easy_setopt(pCurl, CURLOPT_URL, newUrl);

// without curl_multi_remove_handle & curl_multi_add_handle?

user5266221
  • 33
  • 1
  • 6

1 Answers1

1

No, you don't change the URL of an active transfer. Instead, enable pipelining on the multi handle and then add one easy handle for each transfer; the multi handle will pipeline the requests over the same connection if possible.

Andrew Lambert
  • 1,869
  • 1
  • 17
  • 31
  • thank you for your response. So if I have to queue up a new request while previous one is still pending, create a new easy handle with new url and add to multi? is that the best way to do it? – user5266221 Sep 01 '16 at 16:06
  • Yes, and if the server supports pipelining (and you've enabled that option for the multi handle) then they'll automatically share the same connection. – Andrew Lambert Sep 01 '16 at 16:43
  • Note though that if both ends can do HTTP/2, you can ask curl to do multiplexing (using the same option) and then the subsequent transfers can start immediately and be done in parallel. – Daniel Stenberg Sep 02 '16 at 06:11
  • Thank you Andrew and Daniel – user5266221 Sep 02 '16 at 18:04