# File lib/em-http/client.rb, line 261
    def connection_completed
      # if a socks proxy is specified, then a connection request
      # has to be made to the socks server and we need to wait
      # for a response code
      if socks_proxy? and @state == :response_header
        @state = :connect_socks_proxy
        send_socks_handshake

        # if we need to negotiate the proxy connection first, then
        # issue a CONNECT query and wait for 200 response
      elsif connect_proxy? and @state == :response_header
        @state = :connect_http_proxy
        send_request_header

        # if connecting via proxy, then state will be :proxy_connected,
        # indicating successful tunnel. from here, initiate normal http
        # exchange

      else
        @state = :response_header
        ssl = @options[:tls] || @options[:ssl] || {}
        start_tls(ssl) if @uri.scheme == "https" or @uri.port == 443
        send_request_header
        send_request_body
      end
    end