class RDF::Util::File::FaradayAdapter
Use Faraday for retrieving resources @since 1.2
Public Class Methods
Source
# File lib/rdf/util/file.rb, line 190 def conn @conn ||= Faraday.new do |conn| conn.use FaradayMiddleware::FollowRedirects conn.adapter Faraday.default_adapter end end
Get the Faraday::Connection to use for retrieving RDF
resources, or a default connect that follows redirects.
Source
# File lib/rdf/util/file.rb, line 183 def conn= conn @conn = conn end
Set the Faraday::Connection to use for retrieving RDF
resources
Source
# File lib/rdf/util/file.rb, line 199 def self.open_url(base_uri, proxy: nil, headers: {}, verify_none: false, **options) response = conn.get do |req| req.url base_uri headers(headers: headers).each do |k,v| req.headers[k] = v end end case response.status when 200..299 # found object # If a Location is returned, it defines the base resource for this file, not it's actual ending location document_options = { base_uri: RDF::URI(response.headers.fetch(:location, response.env.url)), code: response.status, headers: response.headers } RemoteDocument.new(response.body, document_options) else raise IOError, "<#{base_uri}>: #{response.status}" end end
(see HttpAdapter.open_url
)