Package org.apache.commons.httpclient.methods

Examples of org.apache.commons.httpclient.methods.HeadMethod


     */
    public boolean headMethod(String path)
        throws HttpException, IOException {

        setClient();
        HeadMethod method = new HeadMethod(URIUtil.encodePathQuery(path));

        generateTransactionHeader(method);
        generateAdditionalHeaders(method);
        int statusCode = client.executeMethod(method);

View Full Code Here


    CommonsHttpSolrServer httpserver = (CommonsHttpSolrServer)getSolrServer();
    HttpMethodBase m = null;
    if ("GET".equals(method)) {
      m = new GetMethod(httpserver.getBaseURL() + "/select");
    } else if ("HEAD".equals(method)) {
      m = new HeadMethod(httpserver.getBaseURL() + "/select");
    } else if ("POST".equals(method)) {
      m = new PostMethod(httpserver.getBaseURL() + "/select");
    }
    m.setQueryString(new NameValuePair[] { new NameValuePair("q", "solr"),
          new NameValuePair("qt", "standard") });
View Full Code Here

    if ("GET".equals(method)) {
      m=new GetMethod(httpserver.getBaseURL()+"/update/csv");
    } else if ("POST".equals(method)) {
      m=new PostMethod(httpserver.getBaseURL()+"/update/csv");
    } else if ("HEAD".equals(method)) {
      m=new HeadMethod(httpserver.getBaseURL()+"/update/csv");
    }
   
    return m;
  }
View Full Code Here

            if (method.equals(HTTPConstants.POST)) {
                httpMethod = new PostMethod(urlStr);
            } else if (method.equals(HTTPConstants.PUT)){
                httpMethod = new PutMethod(urlStr);
            } else if (method.equals(HTTPConstants.HEAD)){
                httpMethod = new HeadMethod(urlStr);
            } else if (method.equals(HTTPConstants.TRACE)){
                httpMethod = new TraceMethod(urlStr);
            } else if (method.equals(HTTPConstants.OPTIONS)){
                httpMethod = new OptionsMethod(urlStr);
            } else if (method.equals(HTTPConstants.DELETE)){
View Full Code Here

   * @return a Response object with response detail
   * @throws IOException
   */
  public Response head(Cluster cluster, String path, Header[] headers)
      throws IOException {
    HeadMethod method = new HeadMethod();
    int code = execute(cluster, method, null, path);
    headers = method.getResponseHeaders();
    method.releaseConnection();
    return new Response(code, headers, null);
  }
View Full Code Here

    }

    @Override
    public void testConnection() throws Exception {
        HttpClient client = new HttpClient();
        HeadMethod method = new HeadMethod(getRootUrl().toString());
        prepareHttpClient(client, method);
        int status = client.executeMethod(method);
        if (status != HttpStatus.SC_OK) {
            throw new Exception("Content source failed connection test with status code=" + status);
        }
View Full Code Here

    public URLInfo getURLInfo(URL url) {
        return getURLInfo(url, 0);
    }

    public URLInfo getURLInfo(URL url, int timeout) {
        HeadMethod head = null;
        try {
            head = doHead(url, timeout);
            int status = head.getStatusCode();
            head.releaseConnection();
            if (status == HttpStatus.SC_OK) {
                return new URLInfo(true, getResponseContentLength(head), getLastModified(head));
            }
            if (status == HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED) {
                Message.error("Your proxy requires authentication.");
            } else if (String.valueOf(status).startsWith("4")) {
                Message.verbose("CLIENT ERROR: " + head.getStatusText() + " url=" + url);
            } else if (String.valueOf(status).startsWith("5")) {
                Message.warn("SERVER ERROR: " + head.getStatusText() + " url=" + url);
            }
            Message.debug("HTTP response status: " + status + "=" + head.getStatusText() + " url="
                    + url);
        } catch (HttpException e) {
            Message.error("HttpClientHandler: " + e.getMessage() + ":" + e.getReasonCode() + "="
                    + e.getReason() + " url=" + url);
        } catch (UnknownHostException e) {
            Message.warn("Host " + e.getMessage() + " not found. url=" + url);
            Message.info("You probably access the destination server through "
                + "a proxy server that is not well configured.");
        } catch (IOException e) {
            Message.error("HttpClientHandler: " + e.getMessage() + " url=" + url);
        } catch (IllegalArgumentException e) {
            // thrown by HttpClient to indicate the URL is not valid, this happens for instance
            // when trying to download a dynamic version (cfr IVY-390)
        } finally {
            if (head != null) {
                head.releaseConnection();
            }
        }
        return UNAVAILABLE;
    }
View Full Code Here

    private HeadMethod doHead(URL url, int timeout) throws IOException {
        HttpClient client = getClient(url);
        client.setTimeout(timeout);

        HeadMethod head = new HeadMethod(url.toExternalForm());
        head.setDoAuthentication(useAuthentication(url) || useProxyAuthentication());
        client.executeMethod(head);
        return head;
    }
View Full Code Here

        LOG.trace("HTTP GET consumer thread starting: " + this);
        HttpClient httpClient = getReceiveHttpClient();
        URI remoteUrl = getRemoteUrl();

        HeadMethod httpMethod = new HeadMethod(remoteUrl.toString());
        configureMethod(httpMethod);

        int answer = httpClient.executeMethod(httpMethod);
        if (answer != HttpStatus.SC_OK) {
            throw new IOException("Failed to perform GET on: " + remoteUrl + " as response was: " + answer);
View Full Code Here

        update(uri, relPath, new String[] {vUri}, UpdateInfo.UPDATE_BY_VERSION, removeExisting, sessionInfo);
    }

    private boolean exists(SessionInfo sInfo, String uri) {
        HeadMethod method = new HeadMethod(uri);
        try {
            int statusCode = getClient(sInfo).executeMethod(method);
            if (statusCode == DavServletResponse.SC_OK) {
                return true;
            }
        } catch (IOException e) {
            log.error("Unexpected error while testing existence of item.",e);
        } catch (RepositoryException e) {
            log.error(e.getMessage());
        } finally {
            method.releaseConnection();
        }
        return false;
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.methods.HeadMethod

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.