lib/httpx/plugins/response_cache.rb in httpx-1.2.4 vs lib/httpx/plugins/response_cache.rb in httpx-1.2.6

- old
+ new

@@ -38,11 +38,11 @@ # request, subject to the expiration mechanism, unless a cache-control # directive prohibits caching. However, a cache that does not support # the Range and Content-Range headers MUST NOT cache 206 (Partial # Content) responses. response.status != 206 && ( - response.headers.key?("etag") || response.headers.key?("last-modified-at") || response.fresh? + response.headers.key?("etag") || response.headers.key?("last-modified") || response.fresh? ) end def cached_response?(response) response.is_a?(Response) && response.status == 304 @@ -100,9 +100,12 @@ end end module ResponseMethods def copy_from_cached(other) + # 304 responses do not have content-type, which are needed for decoding. + @headers = @headers.class.new(other.headers.merge(@headers)) + @body = other.body.dup @body.rewind end