Close HTTP client persistent connections

 @param [String] reason for closing

 @return [Boolean] false if failed, otherwise true
511012
def close_http_client(reason)
      @http_client.close(reason) if @http_client
      true
    rescue StandardError => e
      ErrorTracker.log(self, "Failed closing connection", e)
      false
    end
897954
def manual_close(self):
        
        if self.is_closed():
            return False

        # Obtain reference to the connection in-use by the calling thread.
        conn = self.connection()

        # A connection will only be re-added to the available list if it is
        # marked as "in use" at the time it is closed. We will explicitly
        # remove it from the "in use" list, call "close()" for the
        # side-effects, and then explicitly close the connection.
        self._in_use.pop(self.conn_key(conn), None)
        self.close()
        self._close(conn, close_conn=True)
126424
def clientConnectionFailed(self, connector, reason):
        
        log.debug("Connect failed: %s", reason)
        self.conn.defunct(reason.value)
525472
function _close()
	{
		if ($this->_connectionID) $this->_connectionID->Close();
		$this->_connectionID = false;
		return true;
	}
309250
async def close(self):
        
        if self._closed:
            return

        await self.http.close()
        self._closed = True

        for voice in self.voice_clients:
            try:
                await voice.disconnect()
            except Exception:
                # if an error happens during disconnects, disregard it.
                pass

        if self.ws is not None and self.ws.open:
            await self.ws.close()

        self._ready.clear()
1251653
def close(self, **kwargs):
        
        self.keep_running = False
        if self.sock:
            self.sock.close(**kwargs)
            self.sock = None
823667
def do_close(self, reason):
        """"""
        if self.closed:
            return
        self.closed = True
        self.reason = reason
        self.incoming.close()
        self.responses.close()
        if not self._closing:
            self.client.channel_failed(self, Failure(reason))
1293533
def on_close(self):
        ''' 

        '''
        log.info('WebSocket connection closed: code=%s, reason=%r', self.close_code, self.close_reason)
        if self.connection is not None:
            self.application.client_lost(self.connection)
981707
def shutdown(self, reason = ConnectionClosed()):
        
        if self._shutdown:
            raise ShutdownError()
        
        self.stop()
       
        self._closing = True
        for connection in self.connections:
            connection.close()
        self.connections = set()
        self._shutdown = True
        if isinstance(reason, ConnectionClosed):
            logger.info("server shutdown")
        else:
            logger.warn("server shutdown, reason %s" % str(reason))
133167
def close(self):
        '''
        
        '''
        if self._closing:
            return
        self._closing = True
        if hasattr(self.sock, 'close'):
            self.sock.close()
292993
def create_http_client
      close_http_client("reconnecting")
      url = @auth_client.send(@type.to_s + "_url")
      Log.info("Connecting to #{@options[:server_name]} via #{url.inspect}")
      options = {:server_name => @options[:server_name]}
      options[:api_version] = @options[:api_version] if @options[:api_version]
      options[:non_blocking] = @options[:non_blocking] if @options[:non_blocking]
      options[:filter_params] = @options[:filter_params] if @options[:filter_params]
      @http_client = RightScale::BalancedHttpClient.new(url, options)
    end
407104
async def close_async(self, context, reason):
        
        logger.info("Connection closed (reason {}, id {}, offset {}, sq_number {})".format(
            reason,
            context.partition_id,
            context.offset,
            context.sequence_number))
906722
def destroy(*args)
      options = args.extract_options!

      # Get connection or search for connection with cid
      if options[:cid]
        conn = connections[options[:cid]]
        cid = options[:cid]
      elsif options[:id]
        conn, cid = find_connection(options[:id])
      end
      return false unless conn && cid

      # Kill connection, remove from keys, and delete from list
      begin
        thr = Thread.new do
          storage.delete(teams_key, conn.id) rescue nil
          storage.delete(tokens_key, conn.id) rescue nil if options[:remove_token]
        end
        thr.join
        connections.delete(cid)
      rescue
        nil
      end
    rescue => err
      on_error(err)
    end
1039899
public static boolean hasCloseHeader(List<String> connectionValues) {
        if (connectionValues == null) {
            return false;
        }
        return connectionValues.stream().anyMatch(v -> v.equalsIgnoreCase("close"));
    }
389877
@Override
  public void onClosing(WebSocket webSocket, int code, String reason) {
    socketOpen = false;
    callback.onDisconnected();
  }
9121
def closed(self, reason):
        """"""
        self.client.remove_connection(self)
        self.protocol.connection_lost(reason)
        if not isinstance(reason, ConnectionClosed):
            logger.warn("connection closed, reason {}".format(reason))
        else:
            logger.info("connection closed")
963866
def close(self):
        
        log.debug('%r: close() proto=%r connector=%r', self, self.proto, self.connector)
        assert self._dDown is None
        self._dDown = Deferred()

        if self.proto is not None:
            self.proto.transport.loseConnection()
        elif self.connector is not None:
            def connectingFailed(reason):
                """
                Handle the failure resulting from cancellation.

                :reason: a `Failure`, most likely a cancellation error (but
                    that's not guaranteed).
                :returns: `None` to handle the failure
                """
                log.debug('%r: connection attempt has been cancelled: %r', self, reason)
                self._dDown.callback(None)

            self.connector.addErrback(connectingFailed)
            self.connector.cancel()
        else:
            # Fake a cleanly closing connection
            self._dDown.callback(None)

        try:
            raise CancelledError(message="Broker client for node_id={} {}:{} was closed".format(
                self.node_id, self.host, self.port))
        except Exception:
            reason = Failure()
        # Cancel any requests
        for correlation_id in list(self.requests.keys()):  # must copy, may del
            self.cancelRequest(correlation_id, reason)
        return self._dDown