Logging raw requests and responses with HTTParty

276 views
Skip to first unread message

Mark Campbell

unread,
Oct 7, 2016, 9:41:55 AM10/7/16
to HTTParty Gem
Hey all, I have a project that I want to log to the text log and record in the database the raw request and the raw response when using HTTParty.

I did some googling and came up with this old thread (https://groups.google.com/forum/#!topic/httparty-gem/HwlQHw7XsMs) but it only indicates how to log to the logger. Further googling reveals this stackoverflow post (http://stackoverflow.com/questions/6917181/capture-specific-request-with-httparty) which says to use this:

@response.request.instance_variable_get(:@raw_request)

This is pretty gross and obviously not supported by the gem itself, plus it also a drawback in that I can't record the raw request I'm about to make until after I've completed the request.

Is there a way to generate it ahead of time and with a better syntax than using instance_variable_get? Should I just look into another gem (if so, which one?)? Should I add the functionality to httparty and make a pull request?

Thanks in advance for the responses!

-Mark
Reply all
Reply to author
Forward
0 new messages