No commit activity in last 3 years
No release in over 3 years
A tiny piece of Rack middleware to set the default Accept: header
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0

Runtime

>= 0
 Project Readme

Rack::AcceptDefault

Rack::AcceptDefault is a tiny piece of middleware that sets default Accept: header when it isn't present, to work around Rails 3.x issues.

Installation

rubygems

gem install rack-accept-default

Usage

require 'rack-accept-default`
use Rack::AcceptDefault

Why

Rails default MIME negotiation (in ActionPack) handles requests without Accept: headers as invalid, and assume it wants the HTML view. This assumption is wrong per RFC 2616 HTTP/1.1 specification.

If no Accept header field is present, then it is assumed that the client accepts all media types

Rack::AcceptDefault is a piece of Rack middleware that provides a convenient way to work around this problem, by setting the */* value to the Accept header when it is not present.

License

MIT License.

Copyright

Copyright 2012- Tatsuhiko Miyagawa