# File lib/protocols/header_and_content.rb, line 40
40:             def receive_line line
41:                 case @hc_mode
42:                 when :discard_blanks
43:                     unless line == ""
44:                         @hc_mode = :headers
45:                         receive_line line
46:                     end
47:                 when :headers
48:                     if line == ""
49:                         raise "unrecognized state" unless @hc_headers.length > 0
50:                         if respond_to?(:receive_headers)
51:                             receive_headers @hc_headers
52:                         end
53:                         # @hc_content_length will be nil, not 0, if there was no content-length header.
54:                         if @hc_content_length.to_i > 0
55:                             set_binary_mode @hc_content_length
56:                         else
57:                             dispatch_request
58:                         end
59:                     else
60:                         @hc_headers << line
61:                         if ContentLengthPattern =~ line
62:                             # There are some attacks that rely on sending multiple content-length
63:                             # headers. This is a crude protection, but needs to become tunable.
64:                             raise "extraneous content-length header" if @hc_content_length
65:                             @hc_content_length = $1.to_i
66:                         end
67:                         if @hc_headers.length == 1 and respond_to?(:receive_first_header_line)
68:                             receive_first_header_line line
69:                         end
70:                     end
71:                 else
72:                     raise "internal error, unsupported mode"
73:                 end
74:             end