Persistent connection with libcurl

﹥>﹥吖頭↗ 提交于 2019-12-11 12:29:41

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!