Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
35 lines (20 sloc) 880 Bytes


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.



gem install rack-accept-default


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


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.


MIT License.


Copyright 2012- Tatsuhiko Miyagawa

Jump to Line
Something went wrong with that request. Please try again.