Examples of HttpHead


Examples of org.apache.http.client.methods.HttpHead

        super(URI.create(requestURI));
    }

   @Override
    protected HttpUriRequest createRequest(final URI requestURI) {
        return new HttpHead(requestURI);
    }
View Full Code Here

Examples of org.apache.http.client.methods.HttpHead

        return httpClient.execute( httpGet, responseHandler );
    }

    private int pingUrl()
    {
        final HttpHead httpHead = new HttpHead( getWebappUrl() );
        try
        {
            final HttpResponse response = httpClient.execute( httpHead );
            return response.getStatusLine().getStatusCode();
        }
        catch ( IOException e )
        {
            LOG.debug( "Ignoring exception while pinging URL " + httpHead.getURI(), e );
            return -1;
        }
    }
View Full Code Here

Examples of org.apache.http.client.methods.HttpHead

    public boolean resourceExists( String resourceName )
        throws TransferFailedException, AuthorizationException
    {
        String repositoryUrl = getRepository().getUrl();
        String url = repositoryUrl + ( repositoryUrl.endsWith( "/" ) ? "" : "/" ) + resourceName;
        HttpHead headMethod = new HttpHead( url );
        try
        {
            CloseableHttpResponse response = execute( headMethod );
            try
            {
View Full Code Here

Examples of org.apache.http.client.methods.HttpHead

    public boolean resourceExists( String resourceName )
        throws TransferFailedException, AuthorizationException
    {
        String repositoryUrl = getRepository().getUrl();
        String url = repositoryUrl + ( repositoryUrl.endsWith( "/" ) ? "" : "/" ) + resourceName;
        HttpHead headMethod = new HttpHead( url );
        HttpResponse response = null;
        int statusCode;
        try
        {
            response = execute( headMethod );
        }
        catch ( IOException e )
        {
            throw new TransferFailedException( e.getMessage(), e );
        }
        catch ( HttpException e )
        {
            throw new TransferFailedException( e.getMessage(), e );
        }

        try
        {
            statusCode = response.getStatusLine().getStatusCode();
            String reasonPhrase = ", ReasonPhrase:" + response.getStatusLine().getReasonPhrase() + ".";
            switch ( statusCode )
            {
                case HttpStatus.SC_OK:
                    return true;

                case HttpStatus.SC_NOT_MODIFIED:
                    return true;

                case SC_NULL:
                    throw new TransferFailedException( "Failed to transfer file: " + url + reasonPhrase );

                case HttpStatus.SC_FORBIDDEN:
                    throw new AuthorizationException( "Access denied to: " + url + reasonPhrase );

                case HttpStatus.SC_UNAUTHORIZED:
                    throw new AuthorizationException( "Not authorized" + reasonPhrase );

                case HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED:
                    throw new AuthorizationException( "Not authorized by proxy" + reasonPhrase );

                case HttpStatus.SC_NOT_FOUND:
                    return false;

                //add more entries here
                default:
                    throw new TransferFailedException(
                        "Failed to transfer file: " + url + ". Return code is: " + statusCode + reasonPhrase );
            }
        }
        finally
        {
            headMethod.abort();
        }
    }
View Full Code Here

Examples of org.apache.http.client.methods.HttpHead

    return new ApacheHttpRequest(httpClient, new HttpGet(url));
  }

  @Override
  public ApacheHttpRequest buildHeadRequest(String url) {
    return new ApacheHttpRequest(httpClient, new HttpHead(url));
  }
View Full Code Here

Examples of org.apache.http.client.methods.HttpHead

    assertTrue(payload.contains("error"));
  }

  @Test
  public void unsupportedMethod() throws Exception {
    HttpResponse response = getHttpClient().execute(new HttpHead(getEndpoint()));
    assertEquals(HttpStatusCodes.NOT_IMPLEMENTED.getStatusCode(), response.getStatusLine().getStatusCode());

    response = getHttpClient().execute(new HttpOptions(getEndpoint()));
    assertEquals(HttpStatusCodes.NOT_IMPLEMENTED.getStatusCode(), response.getStatusLine().getStatusCode());
  }
View Full Code Here

Examples of org.apache.http.client.methods.HttpHead

            final HttpResponse response,
            final HttpContext context) throws ProtocolException {
        final URI uri = getLocationURI(request, response, context);
        final String method = request.getRequestLine().getMethod();
        if (method.equalsIgnoreCase(HttpHead.METHOD_NAME)) {
            return new HttpHead(uri);
        } else if (method.equalsIgnoreCase(HttpGet.METHOD_NAME)) {
            return new HttpGet(uri);
        } else {
            final int status = response.getStatusLine().getStatusCode();
            if (status == HttpStatus.SC_TEMPORARY_REDIRECT) {
View Full Code Here

Examples of org.apache.http.client.methods.HttpHead

            }
            httpMethod = enclosingMethod;
      } else if ("GET".equals(methodType)) {
        httpMethod = new HttpGet(requestUri);
      } else if ("HEAD".equals(methodType)) {
        httpMethod = new HttpHead(requestUri);
      } else if ("DELETE".equals(methodType)) {
        httpMethod = new HttpDelete(requestUri);
      }
      for (Map.Entry<String, List<String>> entry : request.getHeaders().entrySet()) {
        httpMethod.addHeader(entry.getKey(), Joiner.on(',').join(entry.getValue()));
View Full Code Here

Examples of org.apache.http.client.methods.HttpHead

    } else if (smethod.equalsIgnoreCase("delete")) {
      HttpDelete method = new HttpDelete(uri);
      ProxyProfiler.profileTimedRequest(timedObject, "create HttpDelete");
      return method;
    } else if (smethod.equalsIgnoreCase("head")) {
      HttpHead method = new HttpHead(uri);
      ProxyProfiler.profileTimedRequest(timedObject, "create HttpHead");
      return method;
    } else if (smethod.equalsIgnoreCase("options")) {
      HttpOptions method = new HttpOptions(uri);
      ProxyProfiler.profileTimedRequest(timedObject, "create HttpOptions");
View Full Code Here

Examples of org.apache.http.client.methods.HttpHead

    public boolean httpHead(Node graphName) {
        return doHead(target(graphName)) ;
    }

    protected boolean doHead(String url) {
        HttpUriRequest httpHead = new HttpHead(url) ;
        try {
            HttpOp.execHttpHead(url, WebContent.defaultGraphAcceptHeader, noResponse, null, null, this.authenticator) ;
            return true ;
        } catch (HttpException ex) {
            if ( ex.getResponseCode() == HttpSC.NOT_FOUND_404 )
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.