Sha256: a7ed2f55ff68a05c6787dfdb0b7fd4d7536d5705a9b8abbdea4ed24b53c6a193
Contents?: true
Size: 788 Bytes
Versions: 13
Compression:
Stored size: 788 Bytes
Contents
require 'rack/mime' require 'rack/respond_to' module Goliath module Rack # Does some basic cleanup / handling of the HTTP_ACCEPT header. # This will remove gzip, deflate, compressed and identity. If # there are no values left the header will be set to \*/\*. # # @example # use Goliath::Rack::DefaultMimeType # class DefaultMimeType def initialize(app) @app = app end def call(env) accept = env['HTTP_ACCEPT'] || '' accept = accept.split(/\s*,\s*/) accept.delete_if { |a| a =~ /gzip|deflate|compressed|identity/ } accept = accept.join(", ") env['HTTP_ACCEPT'] = accept env['HTTP_ACCEPT'] = '*/*' if env['HTTP_ACCEPT'] == '' @app.call(env) end end end end
Version data entries
13 entries across 13 versions & 1 rubygems