Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capture specific request with HTTParty

I would like to capture the full request (raw_request -- what went over the wire) for a given action without using a proxy.

I am aware of the debug_output method on the Class, and that might be part of the solution. But unclear on how to set it on a per request basis.

Consider the following ...

@response = HTTParty.post(@job.callback_url, body: @job.to_json)
notification = Notification.new
notification.response_body = @response.body
notification.response_code = @response.code
notification.request_body = ????

Thanks!

Jonathan

like image 862
Jonathan Avatar asked Aug 02 '11 19:08

Jonathan


3 Answers

@response.request will contain the request object.

like image 131
Sohan Avatar answered Nov 06 '22 11:11

Sohan


      HTTParty.post(url, :body => body, :debug_output => $stdout)
like image 18
Brian Low Avatar answered Nov 06 '22 13:11

Brian Low


Add the following under your include HTTParty line:

debug_output $stdout

This sets an output stream for debugging and the output stream is passed on to Net::HTTP#set_debug_output.

like image 9
Simpleton Avatar answered Nov 06 '22 12:11

Simpleton