def query(req)
    connect() if @state == :INIT
    begin
      timeout(@send_timeout) do
        set_header(req)
        req.dump(@socket)
        # flush the IO stream as IO::sync mode is false
        @socket.flush unless @socket_sync
      end
    rescue Errno::ECONNABORTED, Errno::ECONNRESET, Errno::EPIPE
      close
      raise KeepAliveDisconnected.new
    rescue
      if SSLEnabled and $!.is_a?(OpenSSL::SSL::SSLError)
        raise KeepAliveDisconnected.new
      elsif $!.is_a?(TimeoutError)
        close
        raise
      else
        raise
      end
    end

    @state = :META if @state == :WAIT
    @next_connection = nil
    @requests.push(req)
  end
def query(req)
    connect() if @state == :INIT
    begin
      timeout(@send_timeout) do
        set_header(req)
        req.dump(@socket)
        # flush the IO stream as IO::sync mode is false
        @socket.flush unless @socket_sync
      end
    rescue Errno::ECONNABORTED, Errno::ECONNRESET, Errno::EPIPE
      close
      raise KeepAliveDisconnected.new
    rescue
      if SSLEnabled and $!.is_a?(OpenSSL::SSL::SSLError)
        raise KeepAliveDisconnected.new
      elsif $!.is_a?(TimeoutError)
        close
        raise
      else
        raise
      end
    end

    @state = :META if @state == :WAIT
    @next_connection = nil
    @requests.push(req)
  end
Send a request to the server