Compare commits

...

3 Commits

Author SHA1 Message Date
Matt
cc7e7bcea9
Version bump to 2.7.3 2023-01-16 16:06:59 +00:00
Wladimir Braguini Domingues
f26715c9f3
Update connection.rb documentation (#1482)
Updates connection.rb documentation with PUT example
2023-01-16 16:00:17 +00:00
Aaron Stillwell
bf3ed115fa
Add URL to to_hash in Faraday::Response (#1475)
Co-authored-by: Matt <iMacTia@users.noreply.github.com>
2023-01-16 15:59:23 +00:00
4 changed files with 12 additions and 10 deletions

View File

@ -261,14 +261,13 @@ module Faraday
# @param headers [Hash, nil] unencoded HTTP header key/value pairs.
#
# @example
# # TODO: Make it a PUT example
# conn.post '/items', data, content_type: 'application/json'
# conn.put '/products/123', data, content_type: 'application/json'
#
# # Simple ElasticSearch indexing sample.
# conn.post '/twitter/tweet' do |req|
# req.headers[:content_type] = 'application/json'
# req.params[:routing] = 'kimchy'
# req.body = JSON.generate(user: 'kimchy', ...)
# # Star a gist.
# conn.put 'https://api.github.com/gists/GIST_ID/star' do |req|
# req.headers['Accept'] = 'application/vnd.github+json'
# req.headers['Authorization'] = 'Bearer <YOUR-TOKEN>'
# req.headers['X-GitHub-Api-Version'] = '2022-11-28'
# end
#
# @yield [Faraday::Request] for further request customizations

View File

@ -61,7 +61,8 @@ module Faraday
def to_hash
{
status: env.status, body: env.body,
response_headers: env.response_headers
response_headers: env.response_headers,
url: env.url
}
end

View File

@ -1,5 +1,5 @@
# frozen_string_literal: true
module Faraday
VERSION = '2.7.2'
VERSION = '2.7.3'
end

View File

@ -4,7 +4,7 @@ RSpec.describe Faraday::Response do
subject { Faraday::Response.new(env) }
let(:env) do
Faraday::Env.from(status: 404, body: 'yikes',
Faraday::Env.from(status: 404, body: 'yikes', url: Faraday::Utils.URI('https://lostisland.github.io/faraday'),
response_headers: { 'Content-Type' => 'text/plain' })
end
@ -30,6 +30,7 @@ RSpec.describe Faraday::Response do
it { expect(hash[:status]).to eq(subject.status) }
it { expect(hash[:response_headers]).to eq(subject.headers) }
it { expect(hash[:body]).to eq(subject.body) }
it { expect(hash[:url]).to eq(subject.env.url) }
end
describe 'marshal serialization support' do
@ -45,6 +46,7 @@ RSpec.describe Faraday::Response do
it { expect(loaded.env[:body]).to eq(env[:body]) }
it { expect(loaded.env[:response_headers]).to eq(env[:response_headers]) }
it { expect(loaded.env[:status]).to eq(env[:status]) }
it { expect(loaded.env[:url]).to eq(env[:url]) }
end
describe '#on_complete' do