Create a URL for a target bucket and optional object.

@visibleForTesting
327207
public static function createObjectUrl($bucket, $object = null) {
    $gs_filename = self::createGcsFilename($bucket, $object);
    return CloudStorageTools::getPublicUrl($gs_filename, true);
  }
628863
def _construct_url(self, endpoint):
        """"""
        parsed_url = urlparse(self.host)
        scheme = parsed_url[0]
        host = parsed_url[1]
        # Handle host without a scheme specified (eg. www.example.com)
        if scheme == "":
            scheme = "http"
            host = self.host

        if not endpoint.startswith("/"):
            endpoint = "/" + endpoint
        if self.config["api_version"] is not None:
            endpoint = "/v%d%s" % (self.config["api_version"], endpoint)
        return urlunparse((scheme, host, endpoint, '', '', ''))
851806
protected String buildUrl(AbstractBaseRequest request) throws AbstractCosException {
		String endPoint = this.config.getCosEndPoint();
		int appId = this.cred.getAppId();
		String bucketName = request.getBucketName();
		String cosPath = request.getCosPath();
		cosPath = CommonPathUtils.encodeRemotePath(cosPath);
		return String.format("%s/%s/%s%s", endPoint, appId, bucketName, cosPath);
	}
419095
private static String getDownloadUrl(String bucket, String objectName) {
    return String.format(GCS_URL_FORMAT, bucket, objectName);
  }
595375
public static String createReadableString(String bucketName, String objectName) {
    if (bucketName == null && objectName != null) {
      throw new IllegalArgumentException(
          String.format("Invalid bucketName/objectName pair: gs://%s/%s", bucketName, objectName));
    }
    // TODO(user): Unify this method with other methods that convert bucketName/objectName
    // to a URI; maybe use the single slash for compatibility.
    StringBuilder result = new StringBuilder("gs://");
    if (bucketName != null) {
      result.append(bucketName);
    }
    if (objectName != null) {
      result.append('/').append(objectName);
    }
    return result.toString();
  }
237192
def _initURL(self,
                 org_url,
                 referer_url):
        
        if org_url is not None and org_url != '':
            if not org_url.startswith('http://') and not org_url.startswith('https://'):
                org_url = 'https://' + org_url
            self._org_url = org_url

            if self._org_url.lower().find('/sharing/rest') > -1:
                self._url = self._org_url
            else:
                self._url = self._org_url + "/sharing/rest"

            if self._url.startswith('http://'):
                self._surl = self._url.replace('http://', 'https://')
            else:
                self._surl = self._url

            parsed_url = urlparse(self._org_url)
            self._parsed_org_url = urlunparse((parsed_url[0],parsed_url[1],"","","",""))

        if referer_url is None:
            parsed_org = urlparse(self._org_url)
            self._referer_url = parsed_org.netloc

            url = '{}/portals/self'.format( self._url)

        parameters = {
            'f': 'json'
        }
        portal_info = self._post(url=url,
                                 param_dict=parameters,
                                 securityHandler=self,
                                 proxy_port=self._proxy_port,
                                 proxy_url=self._proxy_url)
        if 'user' in portal_info:
            if 'username' in portal_info['user']:
                self._username = portal_info['user']['username']
1063012
def make_url(invocation, args=[], kwargs={}):
    
    if not invocation.endswith('/'):
        invocation += '/'
    if not invocation.startswith('/'):
        invocation = '/' + invocation

    url = invocation

    for arg in args:
        url += str(arg) + "/"

    if kwargs:
        url = url[:-1]
        url += "?" + urlencode(kwargs)
    
    return url
1123120
function buildUrl(value, options, file) {
  const [gist] = value.split(/[?#]/);

  const [inlineUsername, id] =
    gist.indexOf("/") > 0 ? gist.split("/") : [null, gist];

  // username can come from inline code or options
  const username = inlineUsername || options.username;

  // checks for a valid username
  if (username == null || username.trim().length === 0) {
    throw new Error("Missing username information");
  }

  // checks for a valid id
  if (id == null || id.trim().length === 0) {
    throw new Error("Missing gist id information");
  }

  // builds the url and completes it with the file if any
  let url = `${baseUrl}/${username}/${id}.json`;
  if (file != null) {
    url += `?file=${file}`;
  }

  return url;
}
962331
public void createTargetMetaRequest(TargetMetaDef targetMetaDef, ContextHolder holder) {
		ContainerWrapper containerWrapper = servletContainerFinder.findContainer(holder.getAppContextHolder());
		// get HttpSessionVisitorFactoryImp
		VisitorFactory visitorFactory = (VisitorFactory) containerWrapper.lookup(ComponentKeys.VISITOR_FACTORY);
		// ComponentVisitor is HttpSessionComponentVisitor
		ComponentVisitor cm = visitorFactory.createtVisitor(holder.getSessionHolder(), targetMetaDef);
		TargetMetaRequest targetMetaRequest = new TargetMetaRequest(targetMetaDef, cm);
		targetMetaRequestsHolder.setTargetMetaRequest(targetMetaRequest);
	}
1312903
private static HttpHost determineTarget(HttpUriRequest request) throws ClientProtocolException {
		// A null target may be acceptable if there is a default target.
		// Otherwise, the null target is detected in the director.
		HttpHost target = null;
		URI requestURI = request.getURI();
		if (requestURI.isAbsolute()) {
			target = URIUtils.extractHost(requestURI);
			if (target == null) {
				throw new ClientProtocolException(
						"URI does not specify a valid host name: " + requestURI);
			}
		}
		return target;
	}
135338
public static String getTargetUrl() {
		String targetUrl = System.getenv(ENV_API_URL_KEY);
		if (targetUrl != null) {
			return targetUrl;
		} else {
			targetUrl = apiUrl;
		}
		return targetUrl;
	}
925245
function Resource(url, params, actions, options$$1) {

    var self = this || {}, resource = {};

    actions = assign({},
        Resource.actions,
        actions
    );

    each(actions, function (action, name) {

        action = merge({url: url, params: assign({}, params)}, options$$1, action);

        resource[name] = function () {
            return (self.$http || Http)(opts(action, arguments));
        };
    });

    return resource;
}
877611
@Override
    public T addAsWebInfResource(final URL resource, final String target) throws IllegalArgumentException {
        Validate.notNull(resource, "Resource should be specified");
        Validate.notNullOrEmpty(target, "Target should be specified");

        return addAsWebInfResource(new UrlAsset(resource), target);
    }
51444
static function build($required=null, $optional=null,
                   $policy_url=null,
                   $sreg_ns_uri=Auth_OpenID_SREG_NS_URI,
                   $cls='Auth_OpenID_SRegRequest')
    {
        /** @var Auth_OpenID_SRegRequest $obj */
        $obj = new $cls();

        $obj->required = array();
        $obj->optional = array();
        $obj->policy_url = $policy_url;
        $obj->ns_uri = $sreg_ns_uri;

        if ($required) {
            if (!$obj->requestFields($required, true, true)) {
                return null;
            }
        }

        if ($optional) {
            if (!$obj->requestFields($optional, false, true)) {
                return null;
            }
        }

        return $obj;
    }
1272512
private Observable<ProposedBucketConfigContext> refreshAgainstNode(final String bucketName,
        final NetworkAddress hostname) {
        final Credential credential = registrations().get(bucketName);
        if (credential == null) {
            LOGGER.debug("Ignoring refresh attempt since it seems the bucket registration is gone (closed).");
            return Observable.empty();
        }

        return Observable.defer(new Func0<Observable<BucketConfigResponse>>() {
            @Override
            public Observable<BucketConfigResponse> call() {
                return cluster()
                    .<BucketConfigResponse>send(new BucketConfigRequest(HttpLoader.TERSE_PATH, hostname, bucketName,
                        credential.username(), credential.password()))
                    .flatMap(new Func1<BucketConfigResponse, Observable<BucketConfigResponse>>() {
                        @Override
                        public Observable<BucketConfigResponse> call(BucketConfigResponse response) {
                            if (response.status().isSuccess()) {
                                LOGGER.debug("Successfully got config refresh from terse bucket remote.");
                                return Observable.just(response);
                            }

                            LOGGER.debug("Terse bucket config refresh failed, falling back to verbose.");
                            return cluster().send(
                                new BucketConfigRequest(HttpLoader.VERBOSE_PATH, hostname, bucketName,
                                    credential.username(), credential.password()));
                        }
                    });
            }
        }).map(new Func1<BucketConfigResponse, ProposedBucketConfigContext>() {
            @Override
            public ProposedBucketConfigContext call(final BucketConfigResponse response) {
                String config = response.config().replace("$HOST", hostname.address());
                return new ProposedBucketConfigContext(bucketName, config, hostname);
            }
        }).doOnError(new Action1<Throwable>() {
            @Override
            public void call(Throwable ex) {
                LOGGER.debug("Could not fetch config from bucket \"" + bucketName + "\" against \""
                    + hostname + "\".", ex);
            }
        });
    }
1074226
@Nullable
  public static URL uriToUrl(@Nullable Uri uri) {
    if (uri == null) {
      return null;
    }

    try {
      return new URL(uri.toString());
    } catch (java.net.MalformedURLException e) {
      // This should never happen since we got a valid uri
      throw new RuntimeException(e);
    }
  }
528352
protected function _buildCloudFrontDistributionUrl($protocol, $image, $bucket, $bucketPrefix = null, $cfDist = null) {
		$path = $protocol . '://';
		if (is_string($cfDist)) {
			$path .= $cfDist;
		} else {
			if ($bucketPrefix) {
				$path .= $bucket . '.s3.amazonaws.com';
			} else {
				$path .= 's3.amazonaws.com/' . $bucket;
			}
		}
		$path .= $image;

		return $path;
	}