44: def consume_line line
45: if @state == :precommand
46: unless line =~ /\A\s*\Z/
47: @command = line
48: @state = :headers
49: end
50: elsif @state == :headers
51: if line == ""
52: if @content_length
53: yield( [:sized_text, @content_length+1] )
54: else
55: @state = :body
56: yield( [:unsized_text] )
57: end
58: elsif line =~ /\A([^:]+):(.+)\Z/
59: k = $1.dup.strip
60: v = $2.dup.strip
61: @header[k] = v
62: if k == "content-length"
63: @content_length = v.to_i
64: end
65: else
66:
67: end
68: elsif @state == :body
69: @body = line
70: yield( [:dispatch] )
71: end
72: end