PHP CURL api 是否比使用流进行 HTTP/HTTPS 访问更干净/更快/更好?

发布于 2024-11-07 11:51:45 字数 460 浏览 0 评论 0原文

我目前只使用 PHP 流上下文功能(请参阅 https: //www.php.net/manual/en/function.stream-context-create.php) 来访问 HTTP 资源,我已经能够成功地使用它来执行 PUT、DELETE、POST、管理 cookie并做几乎所有事情我需要做的。我最初开始使用它是因为我在早期的 Debian PHP cURL 版本中遇到了 SSL 问题(Apache 进程中存在 OpenSSL 双重初始化问题,在尝试访问 SSL url 时出错):这些问题现在可能已修复,但我还没有修复有机会回去。

在与朋友的讨论中,他认为 cURL api 更快/更好,所以我想问:是否有任何明确的经验/知识关于哪个选项更优越,以及在哪些方面?

I currently use pretty exclusively the PHP stream context functionality (see https://www.php.net/manual/en/function.stream-context-create.php) to access HTTP resources and I've been able to successfully use it to do PUTs, DELETEs, POSTs, manage cookies and do just about everything I've needed to do. I originally started using it because I had SSL issues with earlier Debian PHP cURL builds (there was an OpenSSL double-initialization issue within the Apache process that errored out when trying to access SSL urls): those are probably fixed now but I've not had occasion to go back.

In discussions with a friend he contended that the cURL api is faster/better so I wanted to ask: is there any definite experience/knowledge about which option is superior, and in what ways?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

当梦初醒 2024-11-14 11:51:45

根据我的经验,流非常整洁。您可能已经知道了,但这里有一篇关于流的文章,以防万一不知道:

http://fabien.potencier.org/article/44/php-iterators-and-streams-are-awesome

Curl 很好、快速、简单;但老实说,出于性能原因,我不喜欢其中之一。我从未测量过,但我怀疑它与一开始执行远程请求的开销相比有那么大的差异。

Streams are pretty neat in my experience. You probably know it already, but here's a post on streams with a twist in case not:

http://fabien.potencier.org/article/44/php-iterators-and-streams-are-awesome

Curl is nice and fast, and simple; but I honestly wouldn't prefer one or the other for performance reasons. I've never measured but I doubt it makes that much of a difference in comparison with the overhead of doing a remote request in the first place.

意犹 2024-11-14 11:51:45

在性能方面,cURL 胜出很多< /罢工>始终如一。我不会否认它更难使用,并且对于一般用途来说可能并不重要,但差异非常显着,我认为值得指出。

In regards to performance, cURL wins by a lot consistently. I won't deny that it's harder to use and it might not matter for general use, but the difference was pretty dramatic and I thought it was worth pointing out.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文