public HttpResponse doHEAD(String query, String username, String password) { HttpHead httpHead = new HttpHead(context + query); return doRequest(httpHead, username, password); }
public static void testUrl(String url) throws IOException { HttpHead head = new HttpHead(url); HttpClient httpclient = getClient(); HttpResponse response = httpclient.execute(head); StatusLine status = response.getStatusLine(); if (status.getStatusCode() == 404) { throw new FileNotFoundException(); } if (status.getStatusCode() != 200) { throw new RuntimeException("Could not get URL: " + status.getStatusCode() + ": " + status.getReasonPhrase()); } }
/** * Create a Commons HttpMethodBase object for the given HTTP method and URI specification. * @param httpMethod the HTTP method * @param uri the URI * @return the Commons HttpMethodBase object */ protected HttpUriRequest createHttpUriRequest(HttpMethod httpMethod, URI uri) { switch (httpMethod) { case GET: return new HttpGet(uri); case HEAD: return new HttpHead(uri); case POST: return new HttpPost(uri); case PUT: return new HttpPut(uri); case PATCH: return new HttpPatch(uri); case DELETE: return new HttpDelete(uri); case OPTIONS: return new HttpOptions(uri); case TRACE: return new HttpTrace(uri); default: throw new IllegalArgumentException("Invalid HTTP method: " + httpMethod); } }
/** * Send a HEAD request * @param cluster the cluster definition * @param path the path or URI * @param headers the HTTP headers to include in the request * @return a Response object with response detail * @throws IOException */ public Response head(Cluster cluster, String path, Header[] headers) throws IOException { HttpHead method = new HttpHead(path); try { HttpResponse resp = execute(cluster, method, null, path); return new Response(resp.getStatusLine().getStatusCode(), resp.getAllHeaders(), null); } finally { method.releaseConnection(); } }
private HttpRequestBase createBaseRequest(final URL url, final HttpMethod method) { if (method == HttpMethod.GET) { return new HttpGet(url.toString()); } if (method == HttpMethod.POST) { return new HttpPost(url.toString()); } if (method == HttpMethod.PUT) { return new HttpPut(url.toString()); } if (method == HttpMethod.DELETE) { return new HttpDelete(url.toString()); } if (method == HttpMethod.HEAD) { return new HttpHead(url.toString()); } if (method == HttpMethod.OPTIONS) { return new HttpOptions(url.toString()); } if (method == HttpMethod.TRACE) { return new HttpTrace(url.toString()); } if (method == HttpMethod.PATCH) { return new HttpPatch(url.toString()); } throw new MocoException("unknown HTTP method"); }
void fetchUpdateCheckHeaders(DownloadableFile downloadableFile) throws Exception { String url = downloadableFile.validatedUrl(urlGenerator); final HttpRequestBase request = new HttpHead(url); request.setConfig(RequestConfig.custom().setConnectTimeout(HTTP_TIMEOUT_IN_MILLISECONDS).build()); try ( CloseableHttpClient httpClient = httpClientBuilder.build(); CloseableHttpResponse response = httpClient.execute(request) ) { handleInvalidResponse(response, url); this.md5 = response.getFirstHeader(MD5_HEADER).getValue(); this.sslPort = response.getFirstHeader(SSL_PORT_HEADER).getValue(); this.extraProperties = HeaderUtil.parseExtraProperties(response.getFirstHeader(AGENT_EXTRA_PROPERTIES_HEADER)); } }
/** * This method will send HTTP HEAD request to the camera URL to check whether it's online or * offline. It's online when this request succeed and it's offline if any exception occurs or * response code is 404 Not Found. * * @return True if camera is online, false otherwise */ public boolean isOnline() { LOG.debug("Checking online status for {} at {}", getName(), getURL()); try { return client .execute(new HttpHead(toURI(getURL()))) .getStatusLine() .getStatusCode() != 404; } catch (Exception e) { return false; } }
/** * Create a Commons HttpMethodBase object for the given HTTP method and URI specification. * @param httpMethod the HTTP method * @param uri the URI * @return the Commons HttpMethodBase object */ protected HttpUriRequest createHttpUriRequest(HttpMethod httpMethod, URI uri) { switch (httpMethod) { case GET: return new HttpGet(uri); case HEAD: return new HttpHead(uri); case POST: return new HttpPost(uri); case PUT: return new HttpPut(uri); case PATCH: return new HttpPatch(uri); case DELETE: return new HttpDelete(uri); case OPTIONS: return new HttpOptions(uri); case TRACE: return new HttpTrace(uri); default: throw new IllegalArgumentException("Invalid HTTP method: " + httpMethod); } }
logger.log(Level.INFO, "- Retrieving HTTP HEAD for " + httpApplicationLink + " ..."); HttpHead headMethod = new HttpHead(httpApplicationLink); HttpResponse httpResponse = createHttpClient().execute(headMethod);
.setConnectTimeout(10*1000).setSocketTimeout(15*1000).build(); HttpHead head = new HttpHead(location); head.setConfig(rc);
method = new HttpGet(uri); } else if (method instanceof HttpHead) { method = new HttpHead(uri); } else if (method instanceof HttpDelete) { method = new HttpDelete(uri);
log.debug("GET method created based on client request"); } else if (methodName.equalsIgnoreCase("HEAD")) { httpUriRequest = new HttpHead(url); log.debug("HEAD method created based on client request");
req = new HttpHead(url); break;
private HttpRequestBase createApacheRequest(Request<?> request, String uri, String encodedParams) throws FakeIOException { switch (request.getHttpMethod()) { case HEAD: return new HttpHead(uri); case GET: return wrapEntity(request, new HttpGetWithBody(uri), encodedParams); case DELETE: return new HttpDelete(uri); case OPTIONS: return new HttpOptions(uri); case PATCH: return wrapEntity(request, new HttpPatch(uri), encodedParams); case POST: return wrapEntity(request, new HttpPost(uri), encodedParams); case PUT: return wrapEntity(request, new HttpPut(uri), encodedParams); default: throw new SdkClientException("Unknown HTTP method name: " + request.getHttpMethod()); } }
break; case HEAD: reqObj = new HttpHead(urlToRequest); break;
public HttpResponse executeHeadRequest(final String request, Header... header) throws Exception { return executeRequest(new HttpHead(getHttpServerUri() + "/" + request), header); }
private DestinationAccepts getDestinationAcceptance(final boolean sendAsFlowFile, final String uri, final String transactionId, final HttpContext httpContext) throws IOException { final HttpHead head = new HttpHead(uri); head.setConfig(requestConfig); if (sendAsFlowFile) {
return new HttpHead(request.getUrl()); case Method.OPTIONS: return new HttpOptions(request.getUrl());
return new HttpHead(request.getUrl()); case Method.OPTIONS: return new HttpOptions(request.getUrl());
return new HttpHead(request.getUrl()); case Method.OPTIONS: return new HttpOptions(request.getUrl());