Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Peter Cooperx http://www.petercooper.co.uk/

« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS 

Fetch a URL in Ruby

require 'uri'
require 'net/http'
url = "http://www.whatever.com/whatever.txt"
r = Net::HTTP.get_response(URI.parse(url).host, URI.parse(url).path)


r.code = 200 | 404 | 500, etc
r.body = *text of page*

View returned HTTP header on a request

curl -I http://www.google.com/
« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS