The #to_hash method of the request object may be useful. Here's an example of creating a GET request and checking the headers:
require 'net/http' require 'uri' uri = URI('http://example.com/cached_response') req = Net::HTTP::Get.new(uri.request_uri) req['X-Crazy-Header'] = "This is crazy" puts req.to_hash
And an example of a POST request for setting form data and checking headers and body:
require 'net/http' require 'uri' uri = URI('http://www.example.com/todo.cgi') req = Net::HTTP::Post.new(uri.path) req.set_form_data('from' => '2005-01-01', 'to' => '2005-03-31') puts req.to_hash
source share