使用 HTTParty 捕获特定请求 [英] Capture specific request with HTTParty

查看:52
本文介绍了使用 HTTParty 捕获特定请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在不使用代理的情况下捕获给定操作的完整请求(raw_request——通过网络传输的内容).

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

我知道类上的 debug_output 方法,这可能是解决方案的一部分.但不清楚如何在每个请求的基础上设置它.

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.

考虑以下...

@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 = ????

谢谢!

乔纳森

推荐答案

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

这篇关于使用 HTTParty 捕获特定请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆