问题
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
回答1:
@response.request
will contain the request object.
回答2:
HTTParty.post(url, :body => body, :debug_output => $stdout)
回答3:
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.
来源:https://stackoverflow.com/questions/6917181/capture-specific-request-with-httparty