Class: Goliath::Rack::DefaultMimeType
- Inherits:
-
Object
- Object
- Goliath::Rack::DefaultMimeType
- Defined in:
- lib/goliath/rack/default_mime_type.rb
Overview
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 */*.
Instance Method Summary (collapse)
- - (Object) call(env)
-
- (DefaultMimeType) initialize(app)
constructor
A new instance of DefaultMimeType.
Constructor Details
- (DefaultMimeType) initialize(app)
A new instance of DefaultMimeType
14 15 16 |
# File 'lib/goliath/rack/default_mime_type.rb', line 14 def initialize(app) @app = app end |
Instance Method Details
- (Object) call(env)
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/goliath/rack/default_mime_type.rb', line 18 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 |