/* Create endpoint query string
765362
function createEndpointQS(bidderRequest) {
  const qs = {};

  const ref = getReferrerUrl(bidderRequest);
  if (ref) {
    qs.RefererUrl = encodeURIComponent(ref);
  }

  const can = getCanonicalUrl();
  if (can) {
    qs.CanonicalUrl = encodeURIComponent(can);
  }

  return qs;
}
539016
private static String getHost(final String endpoint) {
        String host = URI.create(endpoint).getHost();
        if (host == null) {
            host = URI.create("http://" + endpoint).getHost();
        }
        return host;
    }
933070
function appendQueryString(url, params){
        var key;
        url = url || '';
        if(params){
            if(url.indexOf('?') === -1){
                url += '?';
            }
            if(typeof params === 'string'){
                url += params;
            } else if (typeof params === 'object'){
                for(key in params){
                    if(!/[?&]$/.test(url)){
                        url += '&';
                    }
                    url += encodeURIComponent(key) + '=' + encodeURIComponent(params[key]);
                }
            }
        }

        return url;
    }
1097113
private function buildUri($endpoint, $path, array $query)
    {
        $queryString = '';
        if (count($query) > 0) {
            $queryString = '?'.urldecode(http_build_query($query));
        }

        return $endpoint.$path.$queryString;
    }
502700
def build_query_string(self, data):
        
        queryValues = []
        keys_to_be_removed = []
        for key, value in data.items():
            if key not in ['version', 'restApi', 'resourcePath']:
                if not key == 'point':
                    queryValues.append('{0}={1}'.format(key, value))
                    keys_to_be_removed.append(key)
                keys_to_be_removed.append(key)
        queryString = '&'.join(queryValues)
        data['query'] = '{0}?{1}'.format(data['point'], queryString)
        for k in list(set(keys_to_be_removed)):
            del data[k]
        return data
1159202
private URI addEndPoint(String endPoint) throws URISyntaxException {

        if (StringUtils.isEmpty(endPoint) || endPoint.equals("/")) {
            return this.baseUri;
        }

        if (this.baseUri.getPath().endsWith("/") || endPoint.startsWith("/")) {
            endPoint = this.baseUri.getPath() + endPoint;
        } else {
            endPoint = this.baseUri.getPath() + "/" + endPoint;
        }

        URI uri = null;

        URIBuilder builder = new URIBuilder();

        builder.setScheme(this.baseUri.getScheme());
        builder.setHost(this.baseUri.getHost());
        builder.setPort(this.baseUri.getPort());
        builder.setPath(endPoint);

        uri = builder.build();
        return uri;
    }
5215
private HttpRequest buildHTTPRequest(final Query<?, ?> query) {
		final String url = API_ENDPOINT + query.getPath();

		HttpRequest request;
		switch (query.getHttpRequestMethod()) {
			case GET:
				request = Unirest.get(url);

				if ((query.getQueryParameters() != null) && !query.getQueryParameters().isEmpty()) {
					((GetRequest) request).queryString(query.getQueryParameters());
				}

				break;

			case POST:
				request = Unirest.post(url);

				if ((query.getQueryParameters() != null) && !query.getQueryParameters().isEmpty()) {
					((HttpRequestWithBody) request).fields(query.getQueryParameters());
				}

				break;

			default:
				request = Unirest.get(url);
		}

		/*
		 * Add any named route parameters to the request (i.e. elements used to build the URI, such as
		 * '/sound/{sound_id}' would have a parameter named 'sound_id').
		 */
		if ((query.getRouteParameters() != null) && !query.getRouteParameters().isEmpty()) {
			for (final Entry<String, String> routeParameter : query.getRouteParameters().entrySet()) {
				request.routeParam(routeParameter.getKey(), routeParameter.getValue());
			}
		}

		return request;
	}
1295595
function build_url($resource, array $query = array()) {
        $url = $this->getEndpoint();
        if ($resource && $this->spaceId) $url .= '/';
        if ($resource) $url .= $resource;
        if (!empty($query)) $url .= '?' . http_build_query($query);
        return $url;
    }
635356
public static WaybackRequest createUrlQueryRequest(String url, String start, String end) {
		WaybackRequest r = new WaybackRequest();
		r.setUrlQueryRequest();
		r.setRequestUrl(url);
		r.setStartTimestamp(start);
		r.setEndTimestamp(end);
		return r;
	}
206280
function _createRequestParams(params){
  var resourcePath = params.resourcePath;

  resourcePath = resourcePath.replace(":domain", params.domain)
    .replace(":projectid", params.projectid)
    .replace(":guid", params.appid);

  log.logger.debug("Creating Request Params For Core ", params);
  var coreHost = params.appMbaasModel.coreHost;
  if(coreHost.indexOf("http") !== 0){
    // We do not know protocol so using https as default one.
    coreHost = "https://" + coreHost;
  }
  return {
    url: url.format(coreHost + resourcePath),
    method: params.method,
    headers: {
      'x-fh-auth-app' : params.apiKey
    },
    json: true,
    body: params.data || {}
  };
}
86889
private String formatQueryUrl(String index, String type, String id, Object query) {
        String queryUrl = String.format(fullQueryTemplate,
                index == null ? "_all" : index,
                type == null ? "_all" : type,
                id == null ? "" : id,
                toQueryParams(query));

        return queryUrl.endsWith("?") ? queryUrl.substring(0, queryUrl.length() - 1) : queryUrl;
    }
1013695
def get_endpoints(query = nil)
      @client.make_request(:get, @client.concat_user_path("#{DOMAIN_PATH}/#{id}/endpoints"), query)[0].map do |i|
        endpoint = EndPoint.new(i, @client)
        endpoint.domain_id = id
        endpoint
      end
    end
529449
async function searchQueryServiceUrl(baseUrl) {
  // Should we really be caching all these NuGet feeds in memory?
  const searchQueryServices = await promisify(regularUpdate)({
    url: `${baseUrl}/index.json`,
    // The endpoint changes once per year (ie, a period of n = 1 year).
    // We minimize the users' waiting time for information.
    // With l = latency to fetch the endpoint and x = endpoint update period
    // both in years, the yearly number of queries for the endpoint are 1/x,
    // and when the endpoint changes, we wait for up to x years to get the
    // right endpoint.
    // So the waiting time within n years is n*l/x + x years, for which a
    // derivation yields an optimum at x = sqrt(n*l), roughly 42 minutes.
    intervalMillis: 42 * 60 * 1000,
    json: true,
    scraper: json =>
      json.resources.filter(
        resource => resource['@type'] === 'SearchQueryService'
      ),
  })
  return randomElementFrom(searchQueryServices)['@id']
}
399306
static function createRequestUri($servicePath, $restPath, $params) {
    $requestUrl = $servicePath . $restPath;
    $uriTemplateVars = array();
    $queryVars = array();
    foreach ($params as $paramName => $paramSpec) {
      // Discovery v1.0 puts the canonical location under the 'location' field.
      if (! isset($paramSpec['location'])) {
        $paramSpec['location'] = $paramSpec['restParameterType'];
      }

      if ($paramSpec['type'] == 'boolean') {
        $paramSpec['value'] = ($paramSpec['value']) ? 'true' : 'false';
      }
      if ($paramSpec['location'] == 'path') {
        $uriTemplateVars[$paramName] = $paramSpec['value'];
      } else {
        if (isset($paramSpec['repeated']) && is_array($paramSpec['value'])) {
          foreach ($paramSpec['value'] as $value) {
            $queryVars[] = $paramName . '=' . rawurlencode($value);
          }
        } else {
          $queryVars[] = $paramName . '=' . rawurlencode($paramSpec['value']);
        }
      }
    }

    if (count($uriTemplateVars)) {
      $uriTemplateParser = new URI_Template_Parser($requestUrl);
      $requestUrl = $uriTemplateParser->expand($uriTemplateVars);
    }
    //FIXME work around for the the uri template lib which url encodes
    // the @'s & confuses our servers.
    $requestUrl = str_replace('%40', '@', $requestUrl);

    if (count($queryVars)) {
      $requestUrl .= '?' . implode($queryVars, '&');
    }

    return $requestUrl;
  }
543527
function addHttpEndpointNames(spec) {
  for(var i = 0; i < spec.endpoints.length; i++) {
    var endpoint = spec.endpoints[i];
    if (endpoint.response.contentType.contentType.toLowerCase() === 'javascript') {
      endpoint.response.contentType.contentType = 'application/json';
      endpoint.response.contentType.eval = true;
    } else {
      endpoint.response.content = endpoint.response.content.replace(/(\r\n|\n|\r)/gm,"");
    }
    endpoint.httpMethod = endpoint.method.toLowerCase();
  }
  return spec;
}
21896
function fetch_query() {
            const key = arg.query_id;
            let value = store_struct.query_result_map.get(key);
            if (endpoint_payload) {
                value = {
                    query: String(arg.query_string),
                    result: JSON.parse(JSON.stringify(endpoint_payload)),
                    }; // eslint-disable-line indent
                store_struct.query_result_map.set(key, value);
            }
            return value
                && (String(arg.query_string) === value.query || undefined)
                && value.result
                ; // eslint-disable-line indent
        }
639880
@Override
    public Query createQuery(String qlString)
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(tc, "em.createQuery(" + qlString + ");\n" + toString());

        return getEMInvocationInfo(false).createQuery(qlString);
    }