org.apache.cxf.jaxrs.client.WebClient.head()方法的使用及代码示例

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

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

WebClient.head介绍

[英]Does HTTP HEAD invocation
[中]HTTP头调用

代码示例

代码示例来源:origin: apache/cxf

@Test
public void testGetHeadBook123WebClient() throws Exception {
  String address = "http://localhost:" + PORT + "/bookstore/getheadbook/";
  WebClient client = WebClient.create(address);
  Response r = client.head();
  assertEquals("HEAD_HEADER_VALUE", r.getMetadata().getFirst("HEAD_HEADER"));
}

代码示例来源:origin: com.redhat.rhevm.api/rhevm-api-cli-base

protected String getTopLink(String rel) {
  String ret = null;
  Response links = null;
  Exception failure = null;
  BindingFactoryManager manager =
    BusFactory.getDefaultBus().getExtension(BindingFactoryManager.class);
  manager.registerBindingFactory(JAXRSBindingFactory.JAXRS_BINDING_ID,
                  new JAXRSBindingFactory());
  try {
    WebClient head = getClient(getBaseUrl());
    links = head.path("/").head();
    ret = links.getStatus() == 200 ? getLink(links, rel) : null;
  } catch (Exception e) {
    failure = e;
  }
  if (failure != null || links.getStatus() != 200) {
    String baseError = "cannot follow " + getBaseUrl() + ", failed with ";
    diagnose(baseError, failure, links, 200);
  }
  return ret;
}

代码示例来源:origin: apache/cxf

@Test
public void testHeadBookByURL() throws Exception {
  WebClient wc =
    WebClient.create("http://localhost:" + PORT
             + "/bookstore/bookurl/http%3A%2F%2Ftest.com%2Frss%2F123");
  Response response = wc.head();
  assertTrue(response.getMetadata().size() != 0);
  assertEquals(0, ((InputStream)response.getEntity()).available());
}

相关文章

WebClient类方法