module WEBrick::HTTPUtils
from webrick/httputils.rb
Public Class Methods
parse_header(raw)
click to toggle source
FIXME: it should be deleted if WEBrick
fix the problem
# File vendor/qwik/lib/qwik/util-webrick.rb, line 63 def parse_header(raw) header = Hash.new([].freeze) field = nil raw.each{|line| case line #when /^([A-Za-z0-9_\-]+):\s*(.*?)\s*\z/om #when /^([A-Za-z0-9_\-\!\#\$\%\&\'\*\+\.\^\`\|\~]+):\s*(.*?)\s*\z/om when /^([A-Za-z0-9_\-~]+):\s*(.*?)\s*\z/om field, value = $1, $2 field.downcase! header[field] = [] unless header.has_key?(field) header[field] << value when /^\s+(.*?)\s*\z/om value = $1 unless field raise "bad header '#{line.inspect}'." end header[field][-1] << ' ' << value else raise "bad header '#{line.inspect}'." end } header.each{|key, values| values.each{|value| value.strip! value.gsub!(/\s+/, ' ') } } header end
parse_query(str)
click to toggle source
FIXME: it should be deleted if WEBRick fix the problem
# File vendor/qwik/lib/qwik/util-webrick.rb, line 97 def parse_query(str) query = Hash.new if str str.split(/[&;]/).each{|x| key, val = x.split(/=/,2) next if key.nil? key = unescape_form(key) val = unescape_form(val.to_s) val = FormData.new(val) val.name = key if query.has_key?(key) query[key].append_data(val) next end query[key] = val } end query end
Private Instance Methods
parse_header(raw)
click to toggle source
FIXME: it should be deleted if WEBrick
fix the problem
# File vendor/qwik/lib/qwik/util-webrick.rb, line 63 def parse_header(raw) header = Hash.new([].freeze) field = nil raw.each{|line| case line #when /^([A-Za-z0-9_\-]+):\s*(.*?)\s*\z/om #when /^([A-Za-z0-9_\-\!\#\$\%\&\'\*\+\.\^\`\|\~]+):\s*(.*?)\s*\z/om when /^([A-Za-z0-9_\-~]+):\s*(.*?)\s*\z/om field, value = $1, $2 field.downcase! header[field] = [] unless header.has_key?(field) header[field] << value when /^\s+(.*?)\s*\z/om value = $1 unless field raise "bad header '#{line.inspect}'." end header[field][-1] << ' ' << value else raise "bad header '#{line.inspect}'." end } header.each{|key, values| values.each{|value| value.strip! value.gsub!(/\s+/, ' ') } } header end
parse_query(str)
click to toggle source
FIXME: it should be deleted if WEBRick fix the problem
# File vendor/qwik/lib/qwik/util-webrick.rb, line 97 def parse_query(str) query = Hash.new if str str.split(/[&;]/).each{|x| key, val = x.split(/=/,2) next if key.nil? key = unescape_form(key) val = unescape_form(val.to_s) val = FormData.new(val) val.name = key if query.has_key?(key) query[key].append_data(val) next end query[key] = val } end query end