Class: Rack::Request
- Inherits:
-
Object
- Object
- Rack::Request
- Defined in:
- lib/sinatra/accept_media_types.rb
Instance Method Summary collapse
-
#accept_media_types ⇒ Object
The media types of the HTTP_ACCEPT header ordered according to their “quality” (preference level), without any media type parameters.
Instance Method Details
#accept_media_types ⇒ Object
The media types of the HTTP_ACCEPT header ordered according to their “quality” (preference level), without any media type parameters.
Examples
env['HTTP_ACCEPT'] #=> 'application/xml;q=0.8,text/html,text/plain;q=0.9'
req = Rack::Request.new(env)
req.accept_media_types #=> ['text/html', 'text/plain', 'application/xml']
req.accept_media_types.prefered #=> 'text/html'
For more information, see:
-
Acept header: www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1
-
Quality values: www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.9
Returns
- AcceptMediaTypes
-
ordered list of accept header’s media types
21 22 23 |
# File 'lib/sinatra/accept_media_types.rb', line 21 def accept_media_types @accept_media_types ||= Rack::AcceptMediaTypes.new(@env['HTTP_ACCEPT']) end |