class EventMachine::Protocols::HttpClient2::Request

def process_header

def process_header
  unless @header_lines.first =~ HttpResponseRE
    @conn.close_connection
    @internal_error = :bad_request
  end
  @version = $1.dup
  @status = $2.dup.to_i
  clen = nil
  chunks = nil
  @header_lines.each_with_index do |e,ix|
    if ix > 0
      hdr,val = e.split(ColonRE,2)
      (@headers[hdr.downcase] ||= []) << val
    end
    if clen == nil and e =~ ClenRE
      clen = $1.dup.to_i
    end
    if e =~ ChunkedRE
      chunks = true
    end
  end
  if clen
    # If the content length is zero we should not call set_text_mode,
    # because a value of zero will make it wait forever, hanging the
    # connection. Just return success instead, with empty content.
    if clen == 0 then
      @content = ""
      @conn.pop_request
      succeed(self)
    else
      @conn.set_text_mode clen
    end
  elsif chunks
    @chunking = true
  else
    # Chunked transfer, multipart, or end-of-connection.
    # For end-of-connection, we need to go the unbind
    # method and suppress its desire to fail us.
    p "NO CLEN"
    p @args[:uri]
    p @header_lines
    @internal_error = :unsupported_clen
    @conn.close_connection
  end
end