Class: RDF::Util::File::HttpAdapter Abstract
- Inherits:
-
Object
- Object
- RDF::Util::File::HttpAdapter
- Defined in:
- lib/rdf/util/file.rb
Overview
This class is abstract.
Subclass and override HttpAdapter.open_url to implement a custom adapter
Direct Known Subclasses
Class Method Summary collapse
-
.default_accept_header ⇒ String
The value for an Accept header.
-
.headers(options) ⇒ Hash
A hash of HTTP request headers.
- .open_url(base_uri, options) ⇒ RemoteDocument, Object abstract
Class Method Details
.default_accept_header ⇒ String
Returns the value for an Accept header.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# 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) ⇒ Hash
Returns A hash of HTTP request headers.
33 34 35 36 37 |
# File 'lib/rdf/util/file.rb', line 33 def self.headers headers = .fetch(:headers, {}) headers['Accept'] ||= default_accept_header headers end |
.open_url(base_uri, options) ⇒ RemoteDocument, Object
This method is abstract.
Returns A RemoteDocument. If a block is given, the result of evaluating the block is returned.
72 73 74 |
# File 'lib/rdf/util/file.rb', line 72 def self.open_url(base_uri, ) raise NoMethodError.new("#{self.inspect} does not implement required method `open_url` for ", "open_url") end |