Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Rack middleware to strip accept headers from non XHR requests
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib/rack
spec
.gitignore
Gemfile
README.mdown
Rakefile
rack-strip_http_accept_headers.gemspec

README.mdown

Rack middleware to strip HTTP accept headers

Strips HTTP_ACCEPT headers for all non XML HTTP requests

HTTP accept headers are generally implemented in such a broken way in the wild, see http://www.gethifi.com/blog/browser-rest-http-accept-headers that unless you really need them it is best to ignore them.

FAQ

  1. Why keep the HTTP accept headers for XML HTTP requests?

    XML HTTP requests are often made from the javascript you have placed in web pages. In these cases you control the accept headers that are sent with the requests and so it is neat to be able to make use of these for content negotiation, so we leave them in.

  2. I want to turn off content negotiation entirely?

    If you are using Rails v3.1 or greater and you want to turn off content negotiation entirely with

    ActionDispatch::Request.ignore_accept_header = true

    Once you have done this HTTP accept header values will be ignored.

Something went wrong with that request. Please try again.