Class: Wayback::Response::ParseMementoPage

Inherits:
Faraday::Response::Middleware
  • Object
show all
Defined in:
lib/wayback/response/parse_memento_page.rb

Instance Method Summary collapse

Instance Method Details

#on_complete(env) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/wayback/response/parse_memento_page.rb', line 11

def on_complete(env)
  if respond_to?(:parse) && ((env[:response_headers] && env[:response_headers]['content-type']) || '').match(/^(text\/html|application\/octet-stream)/i)
    unless [204, 301, 302, 304].include?(env[:status])
      env[:body] = {:id => env[:url].to_s, :html => parse(env[:body])}
    else
      nil
    end
  end
end

#parse(body, *opts) ⇒ Object



7
8
9
# File 'lib/wayback/response/parse_memento_page.rb', line 7

def parse(body, *opts)
  body
end