com.ning.http.client.uri.Uri.getQuery()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(222)

本文整理了Java中com.ning.http.client.uri.Uri.getQuery()方法的一些代码示例,展示了Uri.getQuery()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Uri.getQuery()方法的具体详情如下:
包路径:com.ning.http.client.uri.Uri
类名称:Uri
方法名:getQuery

Uri.getQuery介绍

暂无

代码示例

代码示例来源:origin: com.ning/async-http-client

private void inheritContextQuery(Uri context, boolean isRelative) {
  // see RFC2396 5.2.2: query and fragment inheritance
  if (isRelative && start == end) {
    query = context.getQuery();
  }
}

代码示例来源:origin: com.ning/async-http-client

@Override
public List<Param> getQueryParams() {
  if (queryParams == null)
    // lazy load
    if (isNonEmpty(uri.getQuery())) {
      queryParams = new ArrayList<>(1);
      for (String queryStringParam : uri.getQuery().split("&")) {
        int pos = queryStringParam.indexOf('=');
        if (pos <= 0)
          queryParams.add(new Param(queryStringParam, null));
        else
          queryParams.add(new Param(queryStringParam.substring(0, pos), queryStringParam.substring(pos + 1)));
      }
    } else
      queryParams = Collections.emptyList();
  return queryParams;
}

代码示例来源:origin: com.ning/async-http-client

public T setQueryParams(List<Param> params) {
  // reset existing query
  if (isNonEmpty(request.uri.getQuery()))
    request.uri = request.uri.withNewQuery(null);
  rbQueryParams = params;
  return derived.cast(this);
}

代码示例来源:origin: com.ning/async-http-client

public static String computeRealmURI(Uri uri, boolean useAbsoluteURI, boolean omitQuery) {
  if (useAbsoluteURI) {
    return omitQuery && MiscUtils.isNonEmpty(uri.getQuery()) ? uri.withNewQuery(null).toUrl() : uri.toUrl();
  } else {
    String path = getNonEmptyPath(uri);
    return omitQuery || !MiscUtils.isNonEmpty(uri.getQuery()) ? path : path + "?" + uri.getQuery();
  }
}

代码示例来源:origin: com.ning/async-http-client

private String requestUri(Uri uri, ProxyServer proxyServer, boolean connect) {
  if (connect)
    return getAuthority(uri);
  else if (proxyServer != null && !(useProxyConnect(uri) && config.isUseRelativeURIsWithConnectProxies()))
    return uri.toUrl();
  else {
    String path = getNonEmptyPath(uri);
    if (isNonEmpty(uri.getQuery()))
      return path + "?" + uri.getQuery();
    else
      return path;
  }
}

代码示例来源:origin: com.ning/async-http-client

public Uri encode(Uri uri, List<Param> queryParams) {
  String newPath = encodePath(uri.getPath());
  String newQuery = encodeQuery(uri.getQuery(), queryParams);
  return new Uri(uri.getScheme(),//
      uri.getUserInfo(),//
      uri.getHost(),//
      uri.getPort(),//
      newPath,//
      newQuery);
}

代码示例来源:origin: org.glassfish.grizzly/grizzly-http-client

private void inheritContextQuery(Uri context, boolean isRelative) {
  // see RFC2396 5.2.2: query and fragment inheritance
  if (isRelative && start == end) {
    query = context.getQuery();
  }
}

代码示例来源:origin: org.glassfish.grizzly/grizzly-http-client

public T setQueryParams(List<Param> params) {
  // reset existing query
  if (isNonEmpty(request.uri.getQuery()))
    request.uri = request.uri.withNewQuery(null);
  rbQueryParams = params;
  return derived.cast(this);
}

代码示例来源:origin: javaee/grizzly-ahc

public T setQueryParams(List<Param> params) {
  // reset existing query
  if (isNonEmpty(request.uri.getQuery()))
    request.uri = request.uri.withNewQuery(null);
  rbQueryParams = params;
  return derived.cast(this);
}

代码示例来源:origin: org.glassfish.grizzly/grizzly-http-client

public static String computeRealmURI(Uri uri, boolean useAbsoluteURI, boolean omitQuery) {
  if (useAbsoluteURI) {
    return omitQuery && MiscUtils.isNonEmpty(uri.getQuery()) ? uri.withNewQuery(null).toUrl() : uri.toUrl();
  } else {
    String path = getNonEmptyPath(uri);
    return omitQuery || !MiscUtils.isNonEmpty(uri.getQuery()) ? path : path + "?" + uri.getQuery();
  }
}

代码示例来源:origin: com.ning/async-http-client

} else {
  builder.uri(AsyncHttpProviderUtils.getNonEmptyPath(uri))
      .query(uri.getQuery());

代码示例来源:origin: javaee/grizzly-ahc

@Test
public void testRootRelativeURIWithNonRootContext() {
  Uri context = Uri.create("https://graph.facebook.com/foo/bar");
  
  Uri url = Uri.create(context, "/750198471659552/accounts/test-users?method=get&access_token=750198471659552lleveCvbUu_zqBa9tkT3tcgaPh4");
  
  assertEquals(url.getScheme(), "https");
  assertEquals(url.getHost(), "graph.facebook.com");
  assertEquals(url.getPort(), -1);
  assertEquals(url.getPath(), "/750198471659552/accounts/test-users");
  assertEquals(url.getQuery(), "method=get&access_token=750198471659552lleveCvbUu_zqBa9tkT3tcgaPh4");
}

代码示例来源:origin: javaee/grizzly-ahc

@Test
public void testNonRootRelativeURIWithNonRootContext() {
  Uri context = Uri.create("https://graph.facebook.com/foo/bar");
  
  Uri url = Uri.create(context, "750198471659552/accounts/test-users?method=get&access_token=750198471659552lleveCvbUu_zqBa9tkT3tcgaPh4");
  
  assertEquals(url.getScheme(), "https");
  assertEquals(url.getHost(), "graph.facebook.com");
  assertEquals(url.getPort(), -1);
  assertEquals(url.getPath(), "/foo/750198471659552/accounts/test-users");
  assertEquals(url.getQuery(), "method=get&access_token=750198471659552lleveCvbUu_zqBa9tkT3tcgaPh4");
}

代码示例来源:origin: javaee/grizzly-ahc

@Test
public void testRelativeUriWithConsecutiveDotsFromRoot() {
  Uri context = Uri.create("https://hello.com/");
  Uri url = Uri.create(context, "../../../other/content/img.png");
  assertEquals(url.getScheme(), "https");
  assertEquals(url.getHost(), "hello.com");
  assertEquals(url.getPort(), -1);
  assertEquals(url.getPath(), "/../../../other/content/img.png");
  assertNull(url.getQuery());
}

代码示例来源:origin: javaee/grizzly-ahc

@Test
public void testAbsoluteURIWithContext() {
  Uri context = Uri.create("https://hello.com/foo/bar");
  
  Uri url = Uri.create(context, "https://graph.facebook.com/750198471659552/accounts/test-users?method=get&access_token=750198471659552lleveCvbUu_zqBa9tkT3tcgaPh4");
  
  assertEquals(url.getScheme(), "https");
  assertEquals(url.getHost(), "graph.facebook.com");
  assertEquals(url.getPort(), -1);
  assertEquals(url.getPath(), "/750198471659552/accounts/test-users");
  assertEquals(url.getQuery(), "method=get&access_token=750198471659552lleveCvbUu_zqBa9tkT3tcgaPh4");
}

代码示例来源:origin: javaee/grizzly-ahc

@Test
public void testRelativeUriWithDotsAboveRoot() {
  Uri context = Uri.create("https://hello.com/level1");
  Uri url = Uri.create(context, "../other/content/img.png");
  assertEquals(url.getScheme(), "https");
  assertEquals(url.getHost(), "hello.com");
  assertEquals(url.getPort(), -1);
  assertEquals(url.getPath(), "/../other/content/img.png");
  assertNull(url.getQuery());
}

代码示例来源:origin: javaee/grizzly-ahc

@Test
public void testRelativeUriWithConsecutiveDotsFromRootResource() {
  Uri context = Uri.create("https://hello.com/level1");
  Uri url = Uri.create(context, "../../../other/content/img.png");
  assertEquals(url.getScheme(), "https");
  assertEquals(url.getHost(), "hello.com");
  assertEquals(url.getPort(), -1);
  assertEquals(url.getPath(), "/../../../other/content/img.png");
  assertNull(url.getQuery());
}

代码示例来源:origin: javaee/grizzly-ahc

@Test
public void testRelativeUriWithDots() {
  Uri context = Uri.create("https://hello.com/level1/level2/");
  Uri url = Uri.create(context, "../other/content/img.png");
  assertEquals(url.getScheme(), "https");
  assertEquals(url.getHost(), "hello.com");
  assertEquals(url.getPort(), -1);
  assertEquals(url.getPath(), "/level1/other/content/img.png");
  assertNull(url.getQuery());
}

代码示例来源:origin: javaee/grizzly-ahc

@Test
public void testRelativeUriWithConsecutiveDots() {
  Uri context = Uri.create("https://hello.com/level1/level2/");
  Uri url = Uri.create(context, "../../other/content/img.png");
  assertEquals(url.getScheme(), "https");
  assertEquals(url.getHost(), "hello.com");
  assertEquals(url.getPort(), -1);
  assertEquals(url.getPath(), "/other/content/img.png");
  assertNull(url.getQuery());
}

代码示例来源:origin: org.glassfish.grizzly/grizzly-http-client

public Uri encode(Uri uri, List<Param> queryParams) {
  String newPath = encodePath(uri.getPath());
  String newQuery = encodeQuery(uri.getQuery(), queryParams);
  return new Uri(uri.getScheme(),//
      uri.getUserInfo(),//
      uri.getHost(),//
      uri.getPort(),//
      newPath,//
      newQuery);
}

相关文章