require 'net/http'class String # Returns the contents of the string, assuming it is a url. Could be dangerous. def get(body = nil) resp = perform(:get, body) resp.body end # Attempts to parse <code>self</code> as a URL and then performs an HTTP POST on it, with # the optional parameter as the body of the post. Returns the result of the post. def post(body = nil) resp = perform(:post, body) resp.code_type == Net::HTTPOK end private def perform(get_or_post, body) url = URI.parse self http = Net::HTTP.new(url.host, url.port) return http.send(get_or_post, url.path, body) endend