Module | ActionDispatch::Http::MimeNegotiation |
In: |
lib/action_dispatch/http/mime_negotiation.rb
|
The MIME type of the HTTP request, such as Mime::XML.
For backward compatibility, the post \format is extracted from the X-Post-Data-Format HTTP header if present.
Returns the MIME type for the \format used in the request.
GET /posts/5.xml | request.format => Mime::XML GET /posts/5.xhtml | request.format => Mime::HTML GET /posts/5 | request.format => Mime::HTML or MIME::JS, or request.accepts.first depending on the value of <tt>ActionController::Base.use_accept_header</tt>
Sets the \format by string extension, which can be used to force custom formats that are not controlled by the extension.
class ApplicationController < ActionController::Base before_filter :adjust_format_for_iphone private def adjust_format_for_iphone request.format = :iphone if request.env["HTTP_USER_AGENT"][/iPhone/] end end