I want to fetch some content from a webserver using Net:HTTP, like this:
url = URI.parse('http://www.example.com/index.html') res = Net::HTTP.start(url.host, url.port) {|http| http.get('/index.html') } puts res.body
But I need to limit the get to the first 5kb to reduce the network traffic. How do I do this?
I’m not sure when using Net::HTTP but using OpenURI i usually do the following:
hope this helps.