Capture specific request with HTTParty

冷暖自知 提交于 2019-12-03 16:22:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!