Skip to content

Commit

Permalink
Set the path / if it is empty in order to be compatible with defaul…
Browse files Browse the repository at this point in the history
…t adapter (#28)
  • Loading branch information
genki authored Apr 26, 2023
1 parent 99eb7c0 commit 645d245
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/async/http/faraday/adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ def close
def call(env)
super

# for compatibility with the default adapter
env.url.path = '/' if env.url.path.empty?

Sync do
endpoint = Endpoint.new(env.url)

Expand Down
7 changes: 7 additions & 0 deletions spec/async/http/faraday/adapter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ def get_response(url = endpoint.url, path = '/index', adapter_options: {})
end
end

it "works without initial url and trailing slash (compatiblisity to the original behaviour)" do
response = Faraday.new do |faraday|
faraday.adapter :async_http
end.get 'https://www.google.com'
expect(response).to be_success
end

it 'properly handles chunked responses' do
large_response_size = 65536

Expand Down

0 comments on commit 645d245

Please sign in to comment.