Sha256: 912f5d1ac5786415e7b8e322e47dc5546da0633ccdb696fb2354c754cee00abe
Contents?: true
Size: 654 Bytes
Versions: 4
Compression:
Stored size: 654 Bytes
Contents
require 'open-uri' module Thumbs class Download def initialize(app) @app = app end def call(env) if env['thumbs.remote_url'] begin status, headers, body = [200, {}, open(env['thumbs.remote_url']).read] env['thumbs.logger'] << "download" return [status, headers, body] rescue StandardError, Timeout::Error => e status, headers, body = [404, {'Content-Type' => 'text/plain'}, ["Not found"]] env['thumbs.logger'] << "not_found" return [status, headers, body] end else return @app.call(env) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems