问题
The following is from the libcurl homepage:
curl and libcurl have excellent support for persistent connections when transferring several files from the same server. Curl will attempt to reuse connections for all URLs specified on the same command line/config file, and libcurl will reuse connections for all transfers that are made using the same libcurl handle.
Just to be sure, if I create a CURL handle (curl_easy_init()) and set it's headers, make a HTTP-request, then change the headers and make another request, libcurl will still attempt to use a persistent connection even though the headers have changed?
The libcurl homepage also says
If you use the easy interface, and you call curl_easy_cleanup, all the possibly open connections held by libcurl will be closed and forgotten.
So as long as I dont call curl_easy_cleanup, CURL will attempt to re-use the same connection even though the requests are made with different headers?
Thank you.
回答1:
Yes, that's entirely correct. Keep re-using the same easy handle and libcurl will try to re-use connections as much as possible.
来源:https://stackoverflow.com/questions/28713605/persistent-connection-with-libcurl