简体   繁体   中英

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

      HTTParty.post(url, :body => body, :debug_output => $stdout)

@response.request将包含请求对象。

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM