Return to Snippet

Revision: 5530
at March 13, 2008 16:36 by cczona

Updated Code
require "open-uri"


html=URI.parse(uri).read # string representation is the response body

http_headers=URI.parse(uri).read.meta # this hash's keys are also accessible as OpenURI instance methods, e.g. html.content_type

Revision: 5529
at March 13, 2008 16:26 by cczona

Initial Code
require "open-uri"


puts URI.parse(uri).read
puts '*' * 20
puts URI.parse(uri).read.meta.each { |k, v| puts k + "t" + v}

Initial URL

Initial Description
URI objects can be opened directly by open-uri

Initial Title
parse URI object, and fetch response from it, in one step

Initial Tags
url, textmate, ruby

Initial Language