class HttpHeader
Public Class Methods
new(firstline)
click to toggle source
# File lib/http_header.rb, line 26 def initialize(firstline) @name_table = Hash.new @firstline = firstline end
read(text)
click to toggle source
# File lib/http_header.rb, line 73 def HttpHeader.read(text) firstline = text.lines[0].strip fields = text.lines[1..-1] header = HttpHeader.new FirstLine.read(firstline) fields.each do |line| tokens = line.split ':', 2 name = tokens[0].strip value = tokens[1].strip header[name] = value end header end
Public Instance Methods
[](key)
click to toggle source
Calls superclass method
# File lib/http_header.rb, line 39 def [](key) super _issensitive(key) end
[]=(key, value)
click to toggle source
Calls superclass method
# File lib/http_header.rb, line 43 def []=(key, value) @name_table[_issensitive(key)] = key super _issensitive(key), value end
firstline()
click to toggle source
# File lib/http_header.rb, line 31 def firstline @firstline end
org_keys()
click to toggle source
# File lib/http_header.rb, line 35 def org_keys @name_table.values end
to_s()
click to toggle source
# File lib/http_header.rb, line 52 def to_s s = "#{firstline}\r\n" self.each do |key, value| s << "#{@name_table[key]}: #{value}\r\n" end s << "\r\n" return s end
to_str()
click to toggle source
# File lib/http_header.rb, line 61 def to_str self.to_s end
update!(hash)
click to toggle source
# File lib/http_header.rb, line 48 def update!(hash) hash.each { |k,v| self[k] = v } end
Protected Instance Methods
_issensitive(key)
click to toggle source
# File lib/http_header.rb, line 67 def _issensitive(key) key.respond_to?(:upcase) ? key.upcase : key end