[英]PHP curl Keep-Alive - CURLOPT_FORBID_REUSE
regarding CURLOPT_FORBID_REUSE, the docs says ( http://www.php.net/manual/en/function.curl-setopt.php )关于 CURLOPT_FORBID_REUSE,文档说( http://www.php.net/manual/en/function.curl-setopt.php )
TRUE to force the connection to explicitly close when it
has finished processing, and not be pooled for reuse.
If set to FALSE - can I trust the connection to be automatically pooled and reuse, or do I have to do anything specific in the code to support it?, ie如果设置为 FALSE - 我可以相信连接会自动汇集和重用,还是我必须在代码中做任何特定的事情来支持它?,即
Do I need to use the same handle?我需要使用相同的手柄吗? ie avoid calling curl_init()
again and reuse the same value it previously returned?即避免再次调用curl_init()
用它之前返回的相同值?
Do I need to avoid calling curl_close($ch)
?我需要避免调用curl_close($ch)
吗?
curl_init()
and obtain your handle.您仍然需要调用curl_init()
并获取您的句柄。curl_close()
.您仍然应该调用curl_close()
。 In other words, the interface of curl_*()
methods stays the same.换句话说, curl_*()
方法的接口保持不变。 Your code shouldn't change, regarding the use of CURLOPT_FORBID_REUSE
flag.关于CURLOPT_FORBID_REUSE
标志的使用,您的代码不应更改。
curl_close()
includes, but is not limited to, closing a connection. curl_close()
包括但不限于关闭连接。 It's also to free curl and php resources, do clean up.也是为了释放curl和php资源,做清理。
But really, you should only use CURLOPT_FORBID_REUSE
flag if you suspect that the server your using doesn't have a properly implemented HTTP continuation.但实际上,如果您怀疑您使用的服务器没有正确实现的 HTTP 延续,您应该只使用CURLOPT_FORBID_REUSE
标志。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.