require 'uri' # Override the to_s method in the Net::HTTPRequest standard library # to give more useful debugging output. module Net class HTTPRequest attr_writer :data def to_s uri = URI.parse(path) path_with_querystring = uri.path + (uri.query ? '?' + uri.query : '') str = "\n*******\n" + "#{method} #{path_with_querystring} HTTP/1.1\n" str += "Host: #{uri.host}:#{uri.port}\n" self.each_capitalized do |key, value| str += "#{key}: #{value}\n" end str += "\n" + @data + "\n" unless @data.nil? str += "*******" str end end class HTTPResponse attr_writer :body def to_s str = "\n*******\n" str += "HTTP/#{self.http_version} #{self.code} #{self.message}\n" self.each_capitalized do |key, value| str += "#{key}: #{value}\n" end str += "\n" + self.body + "\n" unless self.body.nil? str += "*******\n" str end end end