From 330775f175daace2ab8f28097c2b933ab9b71fc0 Mon Sep 17 00:00:00 2001 From: Nikolaos Anastopoulos Date: Wed, 22 Jan 2025 18:51:17 +0200 Subject: [PATCH] Represent empty body response as blank string. (#46) --- lib/async/http/faraday/adapter.rb | 2 +- test/async/http/faraday/adapter.rb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/async/http/faraday/adapter.rb b/lib/async/http/faraday/adapter.rb index 370d03d..d0c25dc 100644 --- a/lib/async/http/faraday/adapter.rb +++ b/lib/async/http/faraday/adapter.rb @@ -234,7 +234,7 @@ def with_timeout(task: Async::Task.current) def encoded_body(response) body = response.read - return body if body.nil? + return +'' if body.nil? content_type = response.headers['content-type'] return body unless content_type params = extract_type_parameters(content_type) diff --git a/test/async/http/faraday/adapter.rb b/test/async/http/faraday/adapter.rb index 952d9a3..5bd0494 100644 --- a/test/async/http/faraday/adapter.rb +++ b/test/async/http/faraday/adapter.rb @@ -101,7 +101,8 @@ def get_response(url = bound_url, path = '/index', adapter_options: {}) end it "properly handles no content responses" do - expect(get_response.body).to be_nil + expect(get_response.body).to be == '' + expect(get_response.body).not.to be(:frozen?) end end