Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vcr issue_417 - double http headers on curb redirect #550

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions spec/acceptance/curb/curb_spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ def setup_request(uri, curl, options={})
curl.password = uri.password
curl.timeout = 30
curl.connect_timeout = 30
curl.follow_location = true


if headers = options[:headers]
headers.each {|k,v| curl.headers[k] = v }
Expand Down
53 changes: 44 additions & 9 deletions spec/acceptance/shared/callbacks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,21 +102,56 @@
WebMock.after_request(:except => [:other_lib]) do |_, response|
@response = response
end
http_request(:get, "http://httpstat.us/201")
end

it "should pass real response to callback with status and message" do
expect(@response.status[0]).to eq(201)
expect(@response.status[1]).to eq("Created") unless adapter_info.include?(:no_status_message)
end
describe "for a 201 http status response" do
before do
http_request(:get, "http://httpstat.us/201")
end

it "should pass real response to callback with status and message" do
expect(@response.status[0]).to eq(201)
expect(@response.status[1]).to eq("Created") unless adapter_info.include?(:no_status_message)
end

it "should pass real response to callback with headers" do
expect(@response.headers["Content-Length"]).to eq("11")
end

it "should pass real response to callback with headers" do
expect(@response.headers["Content-Length"]).to eq("11")
it "should pass response to callback with body" do
expect(@response.body.size).to eq(11)
end
end

it "should pass response to callback with body" do
expect(@response.body.size).to eq(11)
describe "for a redirect" do
before do
http_request(:get, "http://httpstat.us/301") # redirects to / with status 200 OK
end

let(:headers) {@response.headers}
let(:date_header) {headers['Date']}
let(:server_header) {headers['Server']}
let(:status_code) {headers['status'][0]}
let(:status_text) {headers['status'][1]}

it "should pass the final response to callback with status and message" do
expect(status_code).to eq(200) #
expect(status_text).to eq("OK") unless adapter_info.include?(:no_status_message)
end

it 'should return one and only one Server http header string' do
expect(server_header).to be_a String
end

it 'should return one and only one Date http header string' do
expect(date_header).to be_a String
end

it 'should a date header string that is a valid date' do
expect(Time.parse(date_header)).to be_a Time
end
end

end
end

Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
require 'patron'
require 'em-http'
require 'typhoeus'
require 'time'
end
if RUBY_PLATFORM =~ /java/
require 'manticore'
Expand Down