class RDF::Util::File::HttpAdapter

@abstract Subclass and override {.open_url} to implement a custom adapter @since 1.2

Public Class Methods

default_accept_header() click to toggle source

@return [String] the value for an Accept header

# File lib/rdf/util/file.rb, line 41
def self.default_accept_header
  # Receive text/html and text/plain at a lower priority than other formats
  reader_types = RDF::Format.reader_types.map do |t|
    case t.to_s
    when /text\/(?:plain|html)/
      "#{t};q=0.5"
    when /application\/xhtml\+xml/
      "#{t};q=0.7"
    else
      t
    end
  end

  (reader_types + %w(*/*;q=0.1)).join(", ")
end
headers(options) click to toggle source

@param [Hash{Symbol => Object}] options @option options [Array, String] :headers

HTTP Request headers

@return [Hash] A hash of HTTP request headers

# File lib/rdf/util/file.rb, line 33
def self.headers options
  headers = options.fetch(:headers, {})
  headers['Accept'] ||= default_accept_header
  headers
end
open_url(base_uri, options) click to toggle source

@abstract @param [String] base_uri to open @param [Hash{Symbol => Object}] options

options are ignored in this implementation. Applications are encouraged
to override this implementation to provide more control over HTTP
headers and redirect following.

@option options [String] :proxy

HTTP Proxy to use for requests.

@option options [Array, String] :headers

HTTP Request headers

@option options [Boolean] :verify_none (false)

Don't verify SSL certificates

@return [RemoteDocument, Object] A {RemoteDocument}. If a block is given, the result of evaluating the block is returned. @raise [IOError] if not found

# File lib/rdf/util/file.rb, line 72
def self.open_url(base_uri, options)
  raise NoMethodError.new("#{self.inspect} does not implement required method `open_url` for ", "open_url")
end