Forum: Ruby Maximum read size with Net::HTTP.get?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
smorabito (Guest)
on 2005-11-18 23:54
(Received via mailing list)

I have a Ruby application that allows users fairly arbitrary access to
URLs.  The application then opens and reads the object at that URL
using Net::HTTP.get() and attempts to parse it as an XML document.

So far so good.

But this is a Rails app open to the general public, and it would be
fairly trivial to write a CGI somewhere that just returns garbage data
forever, leaving open a pretty obvious DoS attack.

I'd like to specify a maximum number of bytes to read with
Net::HTTP.get(), so, for example, if the process had read more than 1MB
it would throw an exception and stop reading.  I haven't been able to
find a way to do that so far, but then I confess to being fairly new to

Does anyone have any ideas or pointers?

This topic is locked and can not be replied to.