67: def consume_line line
68: if @state == :precommand
69: unless line =~ /\A\s*\Z/
70: @command = line
71: @state = :headers
72: end
73: elsif @state == :headers
74: if line == ""
75: if @content_length
76: yield( [:sized_text, @content_length+1] )
77: else
78: @state = :body
79: yield( [:unsized_text] )
80: end
81: elsif line =~ /\A([^:]+):(.+)\Z/
82: k = $1.dup.strip
83: v = $2.dup.strip
84: @header[k] = v
85: if k == "content-length"
86: @content_length = v.to_i
87: end
88: else
89:
90: end
91: elsif @state == :body
92: @body = line
93: yield( [:dispatch] )
94: end
95: end