org.springframework.web.client.RestTemplate.headForHeaders()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(5.9k)|赞(0)|评价(0)|浏览(193)

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

RestTemplate.headForHeaders介绍

暂无

代码示例

代码示例来源:origin: liuyangming/ByteTCC

HttpHeaders headers = restTemplate.headForHeaders(ber.toString());
String instanceId = headers.getFirst(HEADER_PROPAGATION_KEY);

代码示例来源:origin: spring-projects/spring-framework

@Test
public void httpHead() {
  String url = "http://localhost:" + this.port + "/text";
  HttpHeaders headers = getRestTemplate().headForHeaders(url);
  String contentType = headers.getFirst("Content-Type");
  assertNotNull(contentType);
  assertEquals("text/html;charset=utf-8", contentType.toLowerCase());
  assertEquals(3, headers.getContentLength());
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void headForHeaders() throws Exception {
  mockSentRequest(HEAD, "http://example.com");
  mockResponseStatus(HttpStatus.OK);
  HttpHeaders responseHeaders = new HttpHeaders();
  given(response.getHeaders()).willReturn(responseHeaders);
  HttpHeaders result = template.headForHeaders("http://example.com");
  assertSame("Invalid headers returned", responseHeaders, result);
  verify(response).close();
}

代码示例来源:origin: apache/servicecomb-java-chassis

@Override
public HttpHeaders headForHeaders(String url, Object... urlVariables) throws RestClientException {
 return getRestTemplate(url).headForHeaders(url, urlVariables);
}

代码示例来源:origin: apache/servicecomb-java-chassis

@Override
public HttpHeaders headForHeaders(String url, Map<String, ?> urlVariables) throws RestClientException {
 return getRestTemplate(url).headForHeaders(url, urlVariables);
}

代码示例来源:origin: apache/servicecomb-java-chassis

@Override
public HttpHeaders headForHeaders(URI url) throws RestClientException {
 return getRestTemplate(url).headForHeaders(url);
}

代码示例来源:origin: zstackio/zstack

protected void exceptionIfImageSizeGreaterThanAvailableCapacity(String url) {
  if (CoreGlobalProperty.UNIT_TEST_ON) {
    return;
  }
  url = url.trim();
  if (!url.startsWith("http") && !url.startsWith("https")) {
    return;
  }
  String len;
  try {
    HttpHeaders header = restf.getRESTTemplate().headForHeaders(URI.create(url));
    len = header.getFirst("Content-Length");
  } catch (Exception e) {
    throw new OperationFailureException(operr("cannot get image. The image url is %s. Exception is %s", url, e.toString()));
  }
  if (len == null) {
    return;
  }
  long size = Long.valueOf(len);
  if (size > self.getAvailableCapacity()) {
    throw new OperationFailureException(operr("the backup storage[uuid:%s, name:%s] has not enough capacity to download the image[%s]." +
            "Required size:%s, available size:%s", self.getUuid(), self.getName(), url, size, self.getAvailableCapacity()));
  }
}

代码示例来源:origin: zstackio/zstack

HttpHeaders header = restf.getRESTTemplate().headForHeaders(url);
try {
  len = header.getFirst("Content-Length");

代码示例来源:origin: FastBootWeixin/FastBootWeixin

public HttpHeaders headForHeaders(String url, Object... uriVariables) throws RestClientException {
  return restTemplate.headForHeaders(url, uriVariables);
}

代码示例来源:origin: FastBootWeixin/FastBootWeixin

public HttpHeaders headForHeaders(URI url) throws RestClientException {
  return restTemplate.headForHeaders(url);
}

代码示例来源:origin: FastBootWeixin/FastBootWeixin

public HttpHeaders headForHeaders(String url, Map<String, ?> uriVariables) throws RestClientException {
  return restTemplate.headForHeaders(url, uriVariables);
}

代码示例来源:origin: org.springframework.boot/spring-boot-test

/**
 * Retrieve all headers of the resource specified by the URI template.
 * <p>
 * URI Template variables are expanded using the given map.
 * @param url the URL
 * @param urlVariables the map containing variables for the URI template
 * @return all HTTP headers of that resource
 * @throws RestClientException on client-side HTTP error
 * @see RestTemplate#headForHeaders(java.lang.String, java.util.Map)
 */
public HttpHeaders headForHeaders(String url, Map<String, ?> urlVariables)
    throws RestClientException {
  return this.restTemplate.headForHeaders(url, urlVariables);
}

代码示例来源:origin: org.springframework.boot/spring-boot-test

/**
 * Retrieve all headers of the resource specified by the URL.
 * @param url the URL
 * @return all HTTP headers of that resource
 * @throws RestClientException on client-side HTTP error
 * @see RestTemplate#headForHeaders(java.net.URI)
 */
public HttpHeaders headForHeaders(URI url) throws RestClientException {
  return this.restTemplate.headForHeaders(applyRootUriIfNecessary(url));
}

代码示例来源:origin: org.springframework.data/spring-data-riak

public <B, K> boolean containsKey(B bucket, K key) {
 RestTemplate restTemplate = getRestTemplate();
 HttpHeaders headers = null;
 try {
  headers = restTemplate.headForHeaders(defaultUri, bucket, key);
 } catch (ResourceAccessException e) {
 }
 return (null != headers);
}

代码示例来源:origin: io.servicecomb/provider-springmvc

@Override
public HttpHeaders headForHeaders(URI url) throws RestClientException {
 return getRestTemplate(url).headForHeaders(url);
}

代码示例来源:origin: io.servicecomb/provider-springmvc

@Override
public HttpHeaders headForHeaders(String url, Object... urlVariables) throws RestClientException {
 return getRestTemplate(url).headForHeaders(url, urlVariables);
}

代码示例来源:origin: io.servicecomb/provider-springmvc

@Override
public HttpHeaders headForHeaders(String url, Map<String, ?> urlVariables) throws RestClientException {
 return getRestTemplate(url).headForHeaders(url, urlVariables);
}

代码示例来源:origin: org.apache.servicecomb/provider-springmvc

@Override
public HttpHeaders headForHeaders(URI url) throws RestClientException {
 return getRestTemplate(url).headForHeaders(url);
}

代码示例来源:origin: org.apache.servicecomb/provider-springmvc

@Override
public HttpHeaders headForHeaders(String url, Object... urlVariables) throws RestClientException {
 return getRestTemplate(url).headForHeaders(url, urlVariables);
}

代码示例来源:origin: org.apache.servicecomb/provider-springmvc

@Override
public HttpHeaders headForHeaders(String url, Map<String, ?> urlVariables) throws RestClientException {
 return getRestTemplate(url).headForHeaders(url, urlVariables);
}

相关文章