Maximum read size with Net::HTTP.get?

S

smorabito

Folks,

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
Ruby.

Does anyone have any ideas or pointers?

-Seth
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
SterlingLa
Top