Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieving full request string using Ruby curl

Tags:

ruby

curb

I intend to send a request like the following:

c = Curl::Easy.http_post("https://example.com", json_string   
    ) do |curl|
      curl.headers['Accept'] = 'application/json'
      curl.headers['Content-Type'] = 'application/json'
      curl.headers['Api-Version'] = '2.2'
    end

I want to log the exact http request that is being made. Is there a way to get the actual request that was made (base path, query parameters, headers and body)?

like image 661
Mike Malloy Avatar asked Nov 13 '22 13:11

Mike Malloy


1 Answers

The on_debug handler has helped me before. In your example you could try:

curl.on_debug do |type, data|
  puts type, data
end
like image 93
Colin Curtin Avatar answered Nov 15 '22 04:11

Colin Curtin