Sha256: 2a6a06255f25cf3f51dfac8a434196ff4a3f8feb05618f4599f81d8989f6fbbc

Contents?: true

Size: 593 Bytes

Versions: 13

Compression:

Stored size: 593 Bytes

Contents

module Murlsh

  # Set the content type correctly based on accept header and user agent.
  class XhtmlResponse < Rack::Response

    # Set the content type to application/xhtml+xml for anything that
    # claims to accept it, for anything else or IE use text/html.
    def set_content_type(http_accept, http_user_agent)
      self['Content-Type'] = if http_accept and
        http_accept[/((\*|application)\/\*|application\/xhtml\+xml)/i] and
        (!http_user_agent or !http_user_agent[/ msie /i])
        'application/xhtml+xml'
      else
       'text/html'
      end
    end

  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
murlsh-0.11.0 lib/murlsh/xhtml_response.rb
murlsh-0.10.0 lib/murlsh/xhtml_response.rb
murlsh-0.9.0 lib/murlsh/xhtml_response.rb
murlsh-0.8.1 lib/murlsh/xhtml_response.rb
murlsh-0.8.0 lib/murlsh/xhtml_response.rb
murlsh-0.7.0 lib/murlsh/xhtml_response.rb
murlsh-0.6.1 lib/murlsh/xhtml_response.rb
murlsh-0.6.0 lib/murlsh/xhtml_response.rb
murlsh-0.5.2 lib/murlsh/xhtml_response.rb
murlsh-0.5.1 lib/murlsh/xhtml_response.rb
murlsh-0.5.0 lib/murlsh/xhtml_response.rb
murlsh-0.4.0 lib/murlsh/xhtml_response.rb
murlsh-0.3.0 lib/murlsh/xhtml_response.rb