Commit be4f2d63 authored by Boris Bügling's avatar Boris Bügling

Always try GET if HEAD fails when validating URLs.

Fixes problem in CocoaPods/Specs#10341
parent dc49ae52
......@@ -236,7 +236,7 @@ module Pod
loop do
resp = ::REST.head(url)
if resp.status_code == 405
if resp.status_code >= 400
resp = ::REST.get(url)
end
......
......@@ -98,6 +98,7 @@ module Pod
it "checks if the homepage is valid" do
WebMock::API.stub_request(:head, /not-found/).to_return(:status => 404)
WebMock::API.stub_request(:get, /not-found/).to_return(:status => 404)
Specification.any_instance.stubs(:homepage).returns('http://banana-corp.local/not-found/')
@sut.validate
@sut.results.map(&:to_s).first.should.match /The URL (.*) is not reachable/
......@@ -127,6 +128,14 @@ module Pod
@sut.results.length.should.equal 0
end
it "does not fail if the homepage errors on HEAD" do
WebMock::API.stub_request(:head, /page/).to_return( :status => 500 )
WebMock::API.stub_request(:get, /page/).to_return( :status => 200 )
Specification.any_instance.stubs(:homepage).returns('http://banana-corp.local/page/')
@sut.validate
@sut.results.length.should.equal 0
end
it "does not follow redirects infinitely" do
WebMock::API.stub_request(:head, /redirect/).to_return(
:status => 301,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment