This does the full setup process on the request, returning only
 when the connection is actually available.
540538
def setup()
      send_bridge_request
      code = nil
			name = nil
			headers = []
			while (line = gets())
				line = line.strip
				if (line == "")
					case code.to_i
					when 100 # 100 Continue, just a ping. Ignore.
						code = name = nil
						headers = []
						next
					when 101 # 101 Upgrade, successfuly got a connection.
						write("HTTP/1.1 100 Continue\r\n\r\n") # let the server know we're still here.
						return self
					when 401 # 401 Access Denied, key wasn't right.
					  close()
					  raise "HTTP BRIDGE error #{code}: host key was invalid or missing, but required."
					when 503, 504 # 503 Service Unavailable or 504 Gateway Timeout, just retry.
						close()
						sleep_time = headers.find {|header| header["Retry-After"] } || 5
						raise RetryError.new("BRIDGE server timed out or is overloaded, wait #{sleep_time}s to try again.", sleep_time)
					else
						raise "HTTP BRIDGE error #{code}: #{name} waiting for connection."
					end
				end
		
				if (!code && !name) # This is the initial response line
					if (match = line.match(%r{^HTTP/1\.[01] ([0-9]{3,3}) (.*)$}))
						code = match[1]
						name = match[2]
						next
					else
						raise "Parse error in BRIDGE request reply."
					end
				else
					if (match = line.match(%r{^(.+?):\s+(.+)$}))
						headers.push({match[1] => match[2]})
					else
						raise "Parse error in BRIDGE request reply's headers."
					end
				end
			end
			return nil
		end
946201
function Ready()
	{
		if (options.autoconnect)
		{
			// make a connection request immediately (optional)
			parent.GetPSN(true, function() {
				if (options.onReady) options.onReady();
				return;
			});
		}
		else
		{
			// just callback that we're ready (if anyone is listening)
			if (options.onReady) options.onReady();
			return;
		}
	}
383219
def connectShell(connection, protocol):
    
    deferred = connectSession(connection, protocol)
    @deferred.addCallback
    def requestSubsystem(session):
        return session.requestShell()
    return deferred
404301
def get_connection(self, *args, **kwargs):
        ""
        self._checkpid()
        try:
            connection = self._available_connections.pop()
        except IndexError:
            connection = self.make_connection()
        self._in_use_connections.add(connection)
        return connection
159526
def ready(self):
        
        if self._clustering:
            return (all([c.connected for c in self._cluster.values()])
                    and len(self._cluster))
        return (self._connection and self._connection.connected)
423715
def on_get(self, req, resp, **kwargs):
        """"""
        return super().on_get(
            req, resp, handler=self._retrieve, **kwargs
        )
409443
function () {
    // Determine https vs. http
    this.server = this.ssl ?
        https.createServer(this.ssl) :
        http.createServer();

    // Bind to the request
    this.server.on('request', this.handle.bind(this));
  }
450909
def setup_status
      @status = {}
      if @client
        if @mode == :http
          @status = @client.status { |type, state| update_status(type, state) }.dup
        else
          @client.connection_status { |state| update_status(:broker, state) }
          @status[:broker] = :connected
          @status[:auth] = @auth_client.status { |type, state| update_status(type, state) } if @auth_client
        end
      end
      true
    end
1013661
async def start_serving(self,
                            connection_config: ConnectionConfig,
                            loop: Optional[asyncio.AbstractEventLoop] = None) -> None:
        
        self.start_serving_nowait(connection_config, loop)
        await self.wait_until_serving()
892134
def connect_full_direct(self, config):
        
        for input_id, output_id in self.compute_full_connections(config, True):
            connection = self.create_connection(config, input_id, output_id)
            self.connections[connection.key] = connection
254845
public void start() {
    proxy.setTrustAllServers(true);
    if (outsideProxy != null) {
      proxy.setChainedProxy(getProxyAddress(outsideProxy));
    }

    addRequestFilter("authentication", new AuthenticationFilter());
    addRequestFilter("requestSizeWatchdog", new RequestSizeWatchdog());
    addResponseFilter("responseSizeWatchdog", new ResponseSizeWatchdog());
    addResponseFilter("download", new FileDownloadFilter(config));

    proxy.start(config.proxyPort());
    port = proxy.getPort();
  }
156153
def establish_connection(self):
        """"""
        conninfo = self.connection
        if not conninfo.port:
            conninfo.port = self.default_port
        credentials = pika.PlainCredentials(conninfo.userid,
                                            conninfo.password)
        return self._connection_cls(pika.ConnectionParameters(
                                           conninfo.hostname,
                                           port=conninfo.port,
                                           virtual_host=conninfo.virtual_host,
                                           credentials=credentials))
673557
def make_connection(self):
        ""
        connection = self.connection_class(**self.connection_kwargs)
        self._connections.append(connection)
        return connection
1178962
@Setup
    public void setup() {
        System.setProperty("io.netty.buffer.checkAccessible", checkAccessible);
        System.setProperty("io.netty.buffer.checkBounds", checkBounds);
        buffer = bufferType.newBuffer();
    }
720966
def acquire(&callback)
      acq = Proc.new {
        conn = self.find { |conn| conn.available? }
        if not conn.nil? and conn.connected?
          callback.call(conn)
        else
          logger.warn("Failed to acquire available connection, retry after 0.1 second")
          EM.add_timer(0.1, &acq)
        end
      }
      EM.add_timer(0, &acq)
    end
902885
def pre_request(self, response, exc=None):
        
        if response.request.method == 'CONNECT':
            self.start_response(
                '200 Connection established',
                [('content-length', '0')]
            )
            # send empty byte so that headers are sent
            self.future.set_result([b''])
            # proxy - server connection
            upstream = response.connection
            # client - proxy connection
            dostream = self.connection
            # Upgrade downstream connection
            dostream.upgrade(partial(StreamTunnel.create, upstream))
            #
            # upstream upgrade
            upstream.upgrade(partial(StreamTunnel.create, dostream))
            response.fire_event('post_request')
            # abort the event
            raise AbortEvent
        else:
            response.event('data_processed').bind(self.data_processed)
            response.event('post_request').bind(self.post_request)
499919
function onConnect(err) {
    if (err) {
      DEBUG("connect error", err)
      return cb(err)
    }

    DEBUG("connected")

    channel.sendMessage({
      type: "request",
      name: "connect",
      to:   "server",
      id:   "0",
      body: {
        key: config.key
      }
    })
  }