final HttpContext localContext = new BasicHttpContext(); HttpHead head = new HttpHead(uri); head.setHeader("Accept", accept); execute(head, new ResponseHandler<Void>() { public Void handleResponse(HttpResponse response)
final HttpContext localContext = new BasicHttpContext(); HttpHead head = new HttpHead(uri); head.setHeader("Accept", accept); execute(head, new ResponseHandler<Void>() { public Void handleResponse(HttpResponse response)
public static EdmWithCSRF readMetadataWithCSRF(String serviceUri, HttpClient httpClient, Map<String, String> headers, ErrorResultHandler<?> errorHandler, Boolean cacheMetadata,URL metadataFilePath,CacheKey cacheKey,Boolean isCacheRefresh) throws ClientProtocolException, IOException, ODataException { EdmWithCSRF edmWithCSRF = null; HttpResponse httpResponse = null; try { Edm edm = metadataCache.getEdm(serviceUri + "/$metadata", httpClient, headers, errorHandler, cacheMetadata,metadataFilePath,cacheKey,isCacheRefresh); HttpHead httpGet = new HttpHead(serviceUri); httpGet.setHeader(CSRF_HEADER, "Fetch"); if(headers != null) { for(Entry<String, String> e : headers.entrySet()) { httpGet.addHeader(e.getKey(), e.getValue()); } } httpResponse = httpClient.execute(httpGet); ODataConnectivityUtil.checkHttpStatus(httpResponse, errorHandler); // TODO - Code for null check. Header csrfHeader = httpResponse.getFirstHeader(CSRF_HEADER); String csrfToken = csrfHeader == null ? null : csrfHeader.getValue(); edmWithCSRF = new EdmWithCSRF(edm, csrfToken); return edmWithCSRF; } catch (Exception e) { logger.error("Error occurred during create operation of Type : " + e); throw e; }finally { HttpClientUtils.closeQuietly(httpResponse); } }
public HttpResponse headWithout(URI uri, int expectedCode, String[][] headers) throws Exception { HttpHead head = new HttpHead(uri); for (String[] eachHeader : headers) { head.setHeader(eachHeader[0], eachHeader[1]); } HttpResponse resp = client.execute(head); assertEquals(expectedCode, resp.getStatusLine().getStatusCode()); return resp; }
public HttpResponse head(URI uri, int expectedCode, String[][] headers) throws Exception { HttpHead head = new HttpHead(uri); HttpResponse resp = null; try { for (String[] eachHeader : headers) { head.setHeader(eachHeader[0], eachHeader[1]); } resp = client.execute(head); } finally { EntityUtils.consume(resp.getEntity()); } assertEquals(expectedCode, resp.getStatusLine().getStatusCode()); return resp; }
log.info("reading remote resource {}",location); HttpHead head = new HttpHead(location); head.setHeader(ACCEPT, mimetype);
log.info("reading remote resource {}",location); HttpHead head = new HttpHead(location); head.setHeader(ACCEPT, mimetype);