-
Fix VCR failing to replay responses recorded with the
auto_inflatefeature of thehttpgem (#1154)Previously, for a real request made with
HTTP.use(:auto_inflate),after_requestcallbacks got the inflated body together with theContent-Encoding: gzipheader of the compressed one. VCR, hooked into WebMock, recorded both, and replaying the cassette raisedZlib::DataError: incorrect header check, because the feature tried to inflate the body again. With VCR'sdecode_compressed_responseoption, recording raisedZlib::GzipFile::Errorinstead.Callbacks now get the inflated body without the
Content-Encodingheader, as they do for a body that Net::HTTP inflates. AContent-Lengthheader, when the response has one, gives the size of the inflated body. The response the client returns is unchanged, and so are the headers of a response with an empty body, such as one to a HEAD request.A cassette recorded this way replays the response with those headers, while the real response keeps the headers of the compressed body.
This doesn't cover a client that inflates with a subclass of the feature, or responses returned by the
cachingfeature ofhttp6. Callbacks get those as before.Cassettes recorded with older versions that have the
Content-Encodingheader on an inflated body still fail. Record them again, or remove that header from their responses. TheirContent-Lengthis still that of the compressed body.