Within VCR, the one and only way VCR will covert the payload to base64 is if you have configured it to do so [1].
However, some serializers may decide to dump strings as base64. A while back, a change was made to psych [2] that causes it to emit strings tagged as binary (e.g. the encoding) as base64, even if it's just raw ASCII text. I believe this psych change got incorporated into one of the recent MRI 1.9.3 releases (maybe patch level 125, if memory serves?).
Honestly, it seems like a bit of a bug in HTTPClient that response headers are tagged as ASCII-8BIT; I believe according to my prior readings of the HTTP RFCs that only ascii characters are allowed in HTTP headers. Thus, I believe it would be safe for HTTPClient to set the encoding on headers to "US-ASCII". That would fix this issue. If you would like to see this changed, please file an issue with the HTTPClient issue tracker (I've never actually used HTTPClient!).
If you dislike the fact that psych treats ASCII-8BIT strings this way, feel free to file an issue with tenderlove about that. I personally think it makes sense for psych to treat any string that says that is binary as binary.
As far as dealing with this in VCR, there's a simple way provided to do that: use a different serializer. I believe that if you use `:serialize_with => :syck` or `:serialize_with => :json` you'll get a human readable cassette. Alternately, you can easily write your own serializer [2].
Another potential way of dealing with it in VCR: use a `before_record` hook to manually change the encoding of all the strings so that they are set to UTF-8 or whatever you want. Then psych will not base64 encode them. However, I recommend you use this option with care...once you go down this route, you are essentially modifying what's being recorded, which means that you're opening yourself up to having false positive tests that pass because of how you modify things but don't pass when run w/o VCR.
Hmm, I realized it's _possible_ it also prevents VCR's fitler_sensitive_data from working, not sure if it's succesfully filtering from inside a base64 encoded header, but haven't checked yet. I do have an api key echo'd back inside a response header that needs to be filtered.
Nope, VCR's hooks are fine. The base64 encoding psych is doing happens just before the data is written to disk, and it's decoded automatically by psych when deserializing the data. Any code that interacts with a VCR::HTTPInteraction object (or VCR::Request or VCR::Response) will be dealing with non-base64 strings.
HTH,
Myron
c.before_record do |i|i.response.body.scrubend