class WEBrick::HTTPRequest
Constants
- DEFINE_ACCEPT_LANGUAGE
DEFINE_ACCEPT_LANGUAGE
= true
Public Instance Methods
accept_language()
click to toggle source
# File vendor/qwik/lib/qwik/util-webrick.rb, line 45 def accept_language if !defined?(@accept_language) || @accept_language.nil? || @accept_language.empty? parse_accept_language end return @accept_language end
gzip_encoding_supported?()
click to toggle source
# File vendor/qwik/lib/qwik/util-webrick.rb, line 54 def gzip_encoding_supported? /\bgzip\b/.match(self['accept-encoding']) end
parse_accept_language()
click to toggle source
copied from gonzui-0.1 FIXME: it should be deleted if WEBrick
supports the method
# File vendor/qwik/lib/qwik/util-webrick.rb, line 24 def parse_accept_language if self['Accept-Language'] tmp = [] parts = self['Accept-Language'].split(/,\s*/) parts.each {|part| if m = /\A([\w-]+)(?:;q=([\d]+(?:\.[\d]+)))?\z/.match(part) lang = m[1] q = (m[2] or 1).to_f tmp.push([lang, q]) end } @accept_language = tmp.sort_by {|lang, q| q}.map {|lang, q| lang}.reverse else @accept_language = ['en'] # FIXME: should be customizable? end end