I am using patron gem for creating curl request. Here is the code
s = Patron::Session.new
s.connect_timeout = 15
s.timeout = 15
s.base_url = API_URL
s.headers['Date'] = DATE_HEADER
s.headers['Accept'] = 'application/xml'
s.headers['Content-Type'] = 'application/json'
s.headers['Authorization'] = "API" + " " + auth_token
response = s.delete(uri)
response.status
How can I get the original curl request made by this gem?
You can’t. Err… you can, by monkey_patching the
Patron::Session.requestmethod, and yielding the request just before the handling. But beware that this is not the “libcurl” request, as this only exists in C code, it’s aPatron::Requestinstance.Also, beware that your monkey-patching may break at any time, as you have to rewrite the whole method!
You add a
yieldjust before handling the request to libcurl, so you have the opportunity to get it with a block.Here is a hint for a patch: