Hash
# File soap/mimemessage.rb, line 93
def add(key, value)
if key != nil and value != nil
header = parse_rhs(value)
header.key = key
self[key.downcase] = header
end
end
# File soap/mimemessage.rb, line 50
def parse(str)
header_cache = nil
str.each do |line|
case line
when /^\A[^\: \t]+:\s*.+$/
parse_line(header_cache) if header_cache
header_cache = line.sub(/\r?\n\z/, '')
when /^\A\s+(.*)$/
# a continuous line at the beginning line crashes here.
header_cache << line
else
raise RuntimeError.new("unexpected header: #{line.inspect}")
end
end
parse_line(header_cache) if header_cache
self
end
# File soap/mimemessage.rb, line 68
def parse_line(line)
if /^\A([^\: \t]+):\s*(.+)\z/ =~ line
header = parse_rhs($2.strip)
header.key = $1.strip
self[header.key.downcase] = header
else
raise RuntimeError.new("unexpected header line: #{line.inspect}")
end
end
# File soap/mimemessage.rb, line 78
def parse_rhs(str)
a = str.split(/;+\s+/)
header = Header.new
header.str = str
header.root = a.shift
a.each do |pair|
if pair =~ /(\w+)\s*=\s*"?([^"]+)"?/
header[$1.downcase] = $2
else
raise RuntimeError.new("unexpected header component: #{pair.inspect}")
end
end
header
end
Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.
If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.
If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.
If you want to help improve the Ruby documentation, please see Improve the docs, or visit Documenting-ruby.org.