Re: PHP libraries? Function to open remote http doc
| From: | Richard Lynch | Date: | Wed, 13 Dec 2000 22:19:26 +0000 |
| Subject: | Re: PHP libraries? Function to open remote http doc | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-30198@lists.php.net to get a copy of this message | ||
> results before passing them back to the user). I've written a real kludge
> of a function that does basically what I need (sort of like fopen, but
> read-only and with an optional headers field so the caller can pass it
> httpd auth and cookies and what-not), but I can't help but think that this
> sort of function is something which should have been needed by countless
> others already and that someone has already written a complete
implementation.
>
> Perhaps there's a library which incorporates such a function?
I don't know of one, but I want it.
> I also note extreme server loading (a single httpd process can consume
90%+
> of CPU) when fetching remote files like so:
>
> while ( $feof( $fp ) )
> {
> $line = fread( $fp, 4096 );
> fwrite( $fo, $line );
> }
>
> Once negotiation is performed, this is the beef of the script.
Put in some timing code to be sure that you are spending time in this loop.
If you really *are* spending time there, about all I can suggest is altering
4096 to other numbers in the hopes of hitting upon some sort of cache/packet
boundary that lets the two machines talk in sync better or something weird
like that...
Or... is $fo a file? That's going to be pretty slow. Can't you store the
stuff in RAM?