HttpHeaders headers = restTemplate.headForHeaders(ber.toString()); String instanceId = headers.getFirst(HEADER_PROPAGATION_KEY);
@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()); }
@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(); }
@Override public HttpHeaders headForHeaders(String url, Object... urlVariables) throws RestClientException { return getRestTemplate(url).headForHeaders(url, urlVariables); }
@Override public HttpHeaders headForHeaders(String url, Map<String, ?> urlVariables) throws RestClientException { return getRestTemplate(url).headForHeaders(url, urlVariables); }
@Override public HttpHeaders headForHeaders(URI url) throws RestClientException { return getRestTemplate(url).headForHeaders(url); }
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())); } }
HttpHeaders header = restf.getRESTTemplate().headForHeaders(url); try { len = header.getFirst("Content-Length");
public HttpHeaders headForHeaders(String url, Object... uriVariables) throws RestClientException { return restTemplate.headForHeaders(url, uriVariables); }
public HttpHeaders headForHeaders(URI url) throws RestClientException { return restTemplate.headForHeaders(url); }
public HttpHeaders headForHeaders(String url, Map<String, ?> uriVariables) throws RestClientException { return restTemplate.headForHeaders(url, uriVariables); }
/** * 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); }
/** * 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)); }
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); }
@Override public HttpHeaders headForHeaders(URI url) throws RestClientException { return getRestTemplate(url).headForHeaders(url); }
@Override public HttpHeaders headForHeaders(String url, Object... urlVariables) throws RestClientException { return getRestTemplate(url).headForHeaders(url, urlVariables); }
@Override public HttpHeaders headForHeaders(String url, Map<String, ?> urlVariables) throws RestClientException { return getRestTemplate(url).headForHeaders(url, urlVariables); }
@Override public HttpHeaders headForHeaders(URI url) throws RestClientException { return getRestTemplate(url).headForHeaders(url); }
@Override public HttpHeaders headForHeaders(String url, Object... urlVariables) throws RestClientException { return getRestTemplate(url).headForHeaders(url, urlVariables); }
@Override public HttpHeaders headForHeaders(String url, Map<String, ?> urlVariables) throws RestClientException { return getRestTemplate(url).headForHeaders(url, urlVariables); }