Creates a new connection for +uri+
516571
def connection_for uri
    use_ssl = uri.scheme.downcase == 'https'

    net_http_args = [uri.host, uri.port]

    net_http_args.concat @proxy_args if
      @proxy_uri and not proxy_bypass? uri.host, uri.port

    connection = @pool.checkout net_http_args

    http = connection.http

    connection.ressl @ssl_generation if
      connection.ssl_generation != @ssl_generation

    if not http.started? then
      ssl   http if use_ssl
      start http
    elsif expired? connection then
      reset connection
    end

    http.read_timeout = @read_timeout if @read_timeout
    http.keep_alive_timeout = @idle_timeout if @idle_timeout

    return yield connection
  rescue Errno::ECONNREFUSED
    address = http.proxy_address || http.address
    port    = http.proxy_port    || http.port

    raise Error, "connection refused: #{address}:#{port}"
  rescue Errno::EHOSTDOWN
    address = http.proxy_address || http.address
    port    = http.proxy_port    || http.port

    raise Error, "host down: #{address}:#{port}"
  ensure
    # Only perform checkin if we successfully checked a connection out
    if connection
      @pool.checkin net_http_args
    end
  end
29412
public Object openConnection(String endpointUri) throws ConnectionException {
        try {
            Map<String,String> params = getRequestParameters();
            if (params != null && !params.isEmpty()) {
                StringBuffer query = new StringBuffer();
                query.append(endpointUri.indexOf('?') < 0 ? '?' : '&');
                int count = 0;
                for (String name : params.keySet()) {
                    if (count > 0)
                        query.append('&');
                    String encoding = getUrlEncoding();
                    query.append(encoding == null ? name : URLEncoder.encode(name, encoding)).append("=");
                    query.append(encoding == null ? params.get(name) : URLEncoder.encode(params.get(name), encoding));
                    count++;
                }
                endpointUri += query;
            }
            URL url = new URL(endpointUri);

            HttpConnection httpConnection;
            if ("PATCH".equals(getHttpMethod()))
                httpConnection = new HttpAltConnection(url);
            else
                httpConnection = new HttpConnection(url);

            httpConnection.open();
            return httpConnection;
        }
        catch (Exception ex) {
            throw new ConnectionException(ConnectionException.CONNECTION_DOWN, ex.getMessage(), ex);
        }
    }
932056
def to_uri
      h = self.attributes.symbolize_keys.slice(:scheme, :host, :path)
      h[:query] = self.unobfuscated_query || self.query

      return Addressable::URI.new(h)
    end
1227574
private URI createRequestURI(String path,String queryParams) throws URISyntaxException {
        return new URI(j4pServerUrl.getScheme(),
                                  j4pServerUrl.getUserInfo(),
                                  j4pServerUrl.getHost(),
                                  j4pServerUrl.getPort(),
                                  path,
                                  queryParams,null);
    }
219540
function URI(options) {
  if (!(this instanceof URI))
    return new URI(options);

  this.address = new Address();
  this.amount = -1;
  this.label = null;
  this.message = null;
  this.request = null;

  if (options)
    this.fromOptions(options);
}
1240940
function buildHttpURL(uri) {
    var port     = weinre_port
    var pathname = weinre_pathname

    if (pathname == "/index.html") pathname = "/"

    if (weinre_protocol == "file:") {
        return uri
    }

    else if (weinre_protocol == "http:") {
        if (port != "") port = ":" + port

        return weinre_protocol + "//" + weinre_host + port + pathname + uri
    }

    else if (weinre_protocol == "https:") {
        if (port != "") port = ":" + port

        return weinre_protocol + "//" + weinre_host + port + pathname + uri
    }
}
340112
function lookup(uri, opts) {
    if (typeof uri === "object") {
      opts = uri;
      uri = undefined;
    }

    opts = opts || {};

    var parsed = url_1(uri);
    var source = parsed.source;
    var id = parsed.id;
    var path = parsed.path;
    var sameNamespace = cache[id] && path in cache[id].nsps;
    var newConnection = opts.forceNew || opts["force new connection"] || false === opts.multiplex || sameNamespace;

    var io;

    if (newConnection) {
      debug("ignoring socket cache for %s", source);
      io = manager(source, opts);
    } else {
      if (!cache[id]) {
        debug("new io instance for %s", source);
        cache[id] = manager(source, opts);
      }
      io = cache[id];
    }
    if (parsed.query && !opts.query) {
      opts.query = parsed.query;
    }
    return io.socket(parsed.path, opts);
  }
538401
def new_connection
      Connection.new(Backburner.configuration.beanstalk_url) { |conn| Backburner::Hooks.invoke_hook_events(self, :on_reconnect, conn) }
    end
776822
def create_connection():
    """"""
    # REDIS_URL is defined in .env and loaded into the environment by Honcho
    redis_url = os.getenv('REDIS_URL')
    # If it's not defined, use the Redis default
    if not redis_url:
        redis_url = 'redis://localhost:6379'
    urlparse.uses_netloc.append('redis')
    url = urlparse.urlparse(redis_url)
    return redis.StrictRedis(
        host=url.hostname,
        port=url.port,
        db=0,
        password=url.password
    )
1166996
function connect(uri, callback) {
  console.log('connecting to database (' + uri + ')');
  mongo.MongoClient.connect(uri, {safe: true}, function (err, client) {
    if (err) return callback(err);

    db = client;
    db.addListener("error", function (error) {
      console.log("mongo client error: " + error);
    });

    callback(null, db);
  });
}
848269
public URI build()
    {
        StringBuilder builder = new StringBuilder( baseURI.toString() );
        builder.append( path.toString() );
        if ( queryParams != null && !queryParams.isEmpty() ) {
            builder.append( queryParameters() );
        }
        return URI.create( builder.toString() );
    }
746579
def _create(self, **kwargs):
        '''
        '''

        try:
            return super(Service, self)._create(**kwargs)
        except HTTPError as ex:
            if "The configuration was updated successfully but could not be " \
                    "retrieved" not in ex.response.text:
                raise

            # BIG-IP® will create in Common partition if none is given.
            # In order to create the uri properly in this class's load,
            # drop in Common as the partition in kwargs.
            if 'partition' not in kwargs:
                kwargs['partition'] = 'Common'
            # Pop all but the necessary load kwargs from the kwargs given to
            # create. Otherwise, load may fail.
            kwargs_copy = kwargs.copy()
            for key in kwargs_copy:
                if key not in self._meta_data['required_load_parameters']:
                    kwargs.pop(key)
            # If response was created successfully, do a local_update.
            # If not, call to overridden _load method via load
            return self.load(**kwargs)
167188
def uri_with(uri, scheme=None, netloc=None, path=None, params=None, query=None, fragment=None):
    
    old_scheme, old_netloc, old_path, old_params, old_query, old_fragment = urlparse(uri)
    path, _netloc = _normalize_win_path(path)
    return urlunparse((
        scheme or old_scheme,
        netloc or old_netloc,
        path or old_path,
        params or old_params,
        query or old_query,
        fragment or old_fragment
    ))
911970
private SocketChannel connect( URI transportURI ) throws PacketTransportException
    {
        String host = transportURI.getHost();
        int port = transportURI.getPort();
        
        try
        {
        	SocketChannel socketChannel = SocketChannel.open();
        	socketChannel.configureBlocking(false);
        	SocketUtils.setupSocket(socketChannel.socket(),
        			                socketSendBufferSize,
        			                socketRecvBufferSize);
        	        	
            log.debug("#"+id+" opening a TCP connection to "+host+":"+port);
            socketChannel.connect(new InetSocketAddress(host,port));
            
            return socketChannel;
        }
        catch (Exception e)
        {
            log.error("#"+id+" could not connect to "+host+":"+port,e);
            throw new PacketTransportException("Could not connect to "+host+":"+port+" : "+e.toString());
        }
    }
999356
public static ConnectionBuilder connectionBuilder(XnioWorker worker, ByteBufferPool bufferPool, URI uri) {
        return new ConnectionBuilder(worker, bufferPool, uri);
    }
55815
def make_url(self, path, api_root=u'/v2/'):
        """"""
        return urljoin(urljoin(self.url, api_root), path)
832900
def connection(state = nil, &block)
      opts = merge_options(options, state || {})
      validate_options(opts)
      conn_opts = connection_options(opts)

      if @connection && @connection_options == conn_opts
        reuse_connection(&block)
      else
        create_new_connection(conn_opts, &block)
      end
    end