Skip to content

Commit ef85c56

Browse files
authored
Represent empty body response as blank string. (#47)
1 parent edbc869 commit ef85c56

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lib/async/http/faraday/adapter.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def with_timeout(task: Async::Task.current)
234234

235235
def encoded_body(response)
236236
body = response.read
237-
return body if body.nil?
237+
return +'' if body.nil?
238238
content_type = response.headers['content-type']
239239
return body unless content_type
240240
params = extract_type_parameters(content_type)

test/async/http/faraday/adapter.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ def get_response(url = bound_url, path = '/index', adapter_options: {})
101101
end
102102

103103
it "properly handles no content responses" do
104-
expect(get_response.body).to be_nil
104+
expect(get_response.body).to be == ''
105+
expect(get_response.body).not.to be(:frozen?)
105106
end
106107
end
107108

0 commit comments

Comments
 (0)