Skip to content

Commit 3a87a17

Browse files
committed
Add test for http_adaptor when Location is a relative URL. For ruby-rdf/rdf#203.
1 parent 1e2f109 commit 3a87a17

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

lib/rdf/spec/http_adapter.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,18 @@
162162
end
163163
end
164164

165+
it "follows 302 to a relative location" do
166+
rel = "../etc/doap.ttl"
167+
168+
WebMock.stub_request(:get, uri).to_return({status: 302, headers: {"Location" => rel}})
169+
WebMock.stub_request(:get, RDF::URI(uri).join(rel).to_s).to_return({body: "foo"})
170+
RDF::Util::File.open_file(uri) do |f|
171+
expect(f.base_uri).to eq RDF::URI(uri).join(rel).to_s
172+
expect(f.read).to eq "foo"
173+
opened.opened
174+
end
175+
end
176+
165177
it "raises an IOError for HTTP 4xx status codes" do
166178
opened.opened
167179

0 commit comments

Comments
 (0)