# File lib/puma/control_cli.rb, line 117
    def send_request
      uri = URI.parse @options[:control_url]
      
      # create server object by scheme
      @server = case uri.scheme
                when "tcp"
                  TCPSocket.new uri.host, uri.port
                when "unix"
                  UNIXSocket.new "#{uri.host}#{uri.path}"
                else
                  raise "Invalid scheme: #{uri.scheme}"
                end

      if @options[:command] == "status"
        message "Puma is started"
      else
        url = "/#{@options[:command]}"

        if @options.has_key?(:control_auth_token)
          url = url + "?token=#{@options[:control_auth_token]}"
        end

        @server << "GET #{url} HTTP/1.0\r\n\r\n"

        unless data = @server.read
          raise "Server closed connection before responding"
        end

        response = data.split("\r\n")

        if response.empty?
          raise "Server sent empty response"
        end

        (@http,@code,@message) = response.first.split(" ",3)

        if @code == "403"
          raise "Unauthorized access to server (wrong auth token)"
        elsif @code == "404"
          raise "Command error: #{response.last}"
        elsif @code != "200"
          raise "Bad response from server: #{@code}"
        end

        message "Command #{@options[:command]} sent success"
        message response.last if @options[:command] == "stats"
      end
      
      @server.close
    end