toulax@gmail.com
3/25/2007 10:14:00 PM
On Mar 25, 6:49 pm, Timothy Hunter <TimHun...@nc.rr.com> wrote:
> tou...@gmail.com wrote:
> > This works, however it still reads the entire page but only displays
> > the certain amount of bytes. Is it possible to only load the amount of
> > bytes that I specify?
>
> > Say for instance that I have a 10mb file, how do I get the first few
> > bytes of this file without having to read it entirely first?
>
> Specify the number of bytes you want to the read method. Because of
> buffering read may actually read more bytes than you want, but it won't
> be all 10mb.
I tested on a URL with around 200kb and it took the exact same time
reading it all vs reading only 8 bytes. I believe this is done in PHP
via sockets, isn't the same possible with Ruby?