lib/http/native_parser.rb
def parse!(str)
      scanner = StringScanner.new(str)
      begin
        while (!scanner.eos?)
          start_pos = scanner.pos
          send(:"parse_#{@state}", scanner)
          if (scanner.pos == start_pos)
            # if we didn't move forward, we've run out of useful string so throw it back.
            return str
          end
        end
      ensure
        # clear out whatever we managed to scan.
        str[0, scanner.pos] = ""
      end
    end
# Consumes as much of str as it can and then removes it from str. This
# allows you to iteratively pass data into the parser as it comes from
# the client.
Consumes as much of str as it can and then removes it from str. This
allows you to iteratively pass data into the parser as it comes from
the client.
Consumes as much of str as it can and then removes it from str . This allows you to iteratively pass data into the parser as it comes from the client .
def parse!(str)
      scanner = StringScanner.new(str)
      begin
        while (!scanner.eos?)
          start_pos = scanner.pos
          send(:"parse_#{@state}", scanner)
          if (scanner.pos == start_pos)
            return str
          end
        end
      ensure
        str[0, scanner.pos] = ""
      end
    end
def parse! ( str ) scanner = StringScanner . new ( str ) begin while ( ! scanner . eos? ) start_pos = scanner . pos send ( :" parse_ #{ @state } " , scanner ) if ( scanner . pos == start_pos ) return str end end ensure str [ 0 , scanner . pos ] = "" end end
Consumes as much of str as it can and then removes it from str.
Consumes as much of str as it can and then removes it from str .
# if we didn't move forward, we've run out of useful string so throw it back. # clear out whatever we managed to scan.
str