So building upon my other jaunts into Ruby I decided to post some code to make http requests to external urls. It could use come polish and there there is most definitely better mechanisms out there (probably a gem or two… or three) but tis fun to write well… code.
First, here is an example of using it.
require 'Proxy'
class HttpCaller
include Proxy
end
caller = HttpCaller.new
response = caller.call "http://www.somewebsite.com"
if response[:error]
puts response[:object].message
else
response[:object].each_header do |key, value|
puts "#{key}: #{value}"
end
puts response[:object].code.to_s
puts response[:object].body
end
And I have posted the full code sample here.





