lostisland / sawyer

Secret User Agent of HTTP
MIT License
249 stars 75 forks source link

Raw response access for Sawyer::Response #31

Closed matadon closed 5 years ago

matadon commented 10 years ago

Sawyer::Response now exposes #env and #body for accessing raw request data. #data itself now memoizes when first called, rather than handling the response decoding in #initialize.

Sometimes, you just need access to the raw data. In my case, I've got some slightly oddball JSON processing to do, plus some Faraday middleware that stores resuls in response.env.

jbandhauer commented 9 years ago

I'd love to have this get merged to lostisland:master. I was just about to write the exact same change for lazy decoding.

My use case is that I'm using Sawyer in an Octokit-based client to our web service that we build as an SDK that we provide to customers. Sometimes the SDK is used with stand-alone code where the Sawyer objects are perfect. But, sometimes, it is used by the server-side of a webapp where I really just want to return the exact same body received from the web service - w/o having to incur the cost of the decode and re-encode of the Sawyer objects.

Thanks!

technoweenie commented 5 years ago
5   Y E A R S   L A T E R

Thanks for the patch. I'll try to get out another sawyer gem point release this week.