Ruby Net::HTTP - Read only x number of bytes of the body

Posted by bvanderw on Stack Overflow See other posts from Stack Overflow or by bvanderw
Published on 2008-09-17T12:03:40Z Indexed on 2010/03/08 0:52 UTC
Read the original article Hit count: 434

Filed under:
|

It seems like the methods of Ruby's Net::HTTP are all or nothing when it comes to reading the body of a web page. How can I read, say, the just the first 100 bytes of the body?

I am trying to read from a content server that returns a short error message in the body of the response if the file requested isn't available. I need to read enough of the body to determine whether the file is there. The files are huge, so I don't want to get the whole body just to check if the file is available.

© Stack Overflow or respective owner

Related posts about ruby

Related posts about http