On 6/19/07, Ashraf Amayreh <mistknight@gmail.com> wrote:
I use CURL rather than the drupal function because drupal uses fsockets, fsockets are known to have issues when retrieving from HTTP 1.0 as opposed to HTTP 1.1, this is solved by sending specific headers, these headers are ignored on some Linux systems and that may increase the response time by as much as 5x what CURL would take, normally they would be similar in speed although CURL is slightly faster. In specific situations like firewall presence or failure in DNS resolution fsockets may stall for a few minutes. I read about these issues in a number of articles and I also found them listed in the comments under fsocketopen. CURL just saved me the hassle and probably tens of issues :-)

 

http://www.php.net/manual/en/function.fsockopen.php

Finally, with CURL I can support both HTTP and FTP URLs weather they are authenticated with a username and password or not. Only con to using CURL is that it has to be installed on the server machine and enabled in PHP (weather as a module or compiled).

Ashraf,

From the comments at the PHP fsockopen page:
===
EDITORS NOTE: HTTP/1.1 uses persistent connection causing this delay. Use "Connection: close" header to disable it.
===
and
===
Just a note to everyone who is using fsockopen and fread / fgets for a HTTP connection.

Unless you specify "Connection: Close" in your headers you will need to wait for the socket to time out before feof($streamPointer) to return true.

This has wasted 2 days of my time, grr!
===

The first example in the page, before the comments, also does the close for
this reason.

This is detailed in the RFC too
http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html#sec8.1

Are you saying the header Connection: Close is ignored?

Any reason why Drupal should not use HTTP/1.1?