Class | SOAP::MIMEMessage::Headers
In: | soap/mimemessage.rb
Parent: | Hash

### Methods

add parse parse parse_line parse_rhs to_s

### Public Class methods

parse(str)

[Source]

    # File soap/mimemessage.rb, line 46
        def self.parse(str)
          new.parse(str)
        end

### Public Instance methods

add(key, value)

[Source]

    # 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

parse(str)

[Source]

    # 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

parse_line(line)

[Source]

    # 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

parse_rhs(str)

[Source]

    # 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

to_s()

[Source]

    # File soap/mimemessage.rb, line 101
        def to_s
          self.values.collect { |hdr|
            hdr.to_s
          }.join("\r\n")
        end

[Validate]