diff --git a/lib/httpx/plugins/response_cache/file_store.rb b/lib/httpx/plugins/response_cache/file_store.rb index b9e6d2d1..e0a3e662 100644 --- a/lib/httpx/plugins/response_cache/file_store.rb +++ b/lib/httpx/plugins/response_cache/file_store.rb @@ -129,6 +129,7 @@ module HTTPX::Plugins response = request.options.response_class.new(request, status, version, response_headers) response.original_request = original_request + response.finish! ::IO.copy_stream(f, response.body) diff --git a/test/response_cache_file_store_test.rb b/test/response_cache_file_store_test.rb index 113369e6..a7bd42ee 100644 --- a/test/response_cache_file_store_test.rb +++ b/test/response_cache_file_store_test.rb @@ -15,6 +15,13 @@ class ResponseCacheFileStoreTest < Minitest::Test assert File.exist?(store.dir.join(request.response_cache_key)) end + def test_finished + request = make_request("GET", "http://store-cache/") + cached_response(request) + response = store.get(request) + assert response.finished? + end + private def store_class