Package org.apache.http.client

Examples of org.apache.http.client.ClientProtocolException


        }

        try {
            return director.execute(target, request, execContext);
        } catch(HttpException httpException) {
            throw new ClientProtocolException(httpException);
        }
    } // execute
View Full Code Here


            HttpResponse response) throws ClientProtocolException {
        if (response.getStatusLine().getStatusCode() != HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED)
            return;

        if (response.getFirstHeader("Proxy-Authenticate") == null)
            throw new ClientProtocolException(
                    "407 Response did not contain a Proxy-Authentication header");
    }
View Full Code Here

            HttpResponse response) throws ClientProtocolException {
        if (response.getStatusLine().getStatusCode() != HttpStatus.SC_METHOD_NOT_ALLOWED)
            return;

        if (response.getFirstHeader("Allow") == null)
            throw new ClientProtocolException("405 Response did not contain an Allow header.");
    }
View Full Code Here

            HttpResponse response) throws ClientProtocolException {
        if (response.getStatusLine().getStatusCode() != HttpStatus.SC_UNAUTHORIZED)
            return;

        if (response.getFirstHeader("WWW-Authenticate") == null) {
            throw new ClientProtocolException(
                    "401 Response did not contain required WWW-Authenticate challenge header");
        }
    }
View Full Code Here

            HttpResponse response) throws ClientProtocolException {
        if (request.getFirstHeader(HeaderConstants.RANGE) != null)
            return;

        if (response.getFirstHeader(HeaderConstants.CONTENT_RANGE) != null) {
            throw new ClientProtocolException(
                    "Content-Range was returned for a request that did not ask for a Content-Range.");
        }

    }
View Full Code Here

        if (originalProtocol.compareToVersion(CachingHttpClient.HTTP_1_1) >= 0) {
            return;
        }

        if (originalRequestDidNotExpectContinue((RequestWrapper) request)) {
            throw new ClientProtocolException("The incoming request did not contain a "
                    + "100-continue header, but the response was a Status 100, continue.");

        }
    }
View Full Code Here

        }

        try {
            request = requestCompliance.makeRequestCompliant(request);
        } catch (ProtocolException e) {
            throw new ClientProtocolException(e);
        }

        cacheInvalidator.flushInvalidatedCacheEntries(target, request);

        if (!cacheableRequestPolicy.isServableFromCache(request)) {
            return callBackend(target, request, context);
        }

        CacheEntry entry = getCacheEntry(target, request);
        if (entry == null) {
            cacheMisses.getAndIncrement();
            if (log.isDebugEnabled()) {
                RequestLine rl = request.getRequestLine();
                log.debug("Cache miss [host: " + target + "; uri: " + rl.getUri() + "]");

            }
            return callBackend(target, request, context);
        }

        if (log.isDebugEnabled()) {
            RequestLine rl = request.getRequestLine();
            log.debug("Cache hit [host: " + target + "; uri: " + rl.getUri() + "]");

        }
        cacheHits.getAndIncrement();

        if (suitabilityChecker.canCachedResponseBeUsed(target, request, entry)) {
            return responseGenerator.generateResponse(entry);
        }

        if (entry.isRevalidatable()) {
            log.debug("Revalidating the cache entry");

            try {
                return revalidateCacheEntry(target, request, context, entry);
            } catch (IOException ioex) {
                HttpResponse response = responseGenerator.generateResponse(entry);
                response.addHeader(HeaderConstants.WARNING, "111 Revalidation Failed - " + ioex.getMessage());
                log.debug("111 revalidation failed due to exception: " + ioex);
                return response;
            } catch (ProtocolException e) {
                throw new ClientProtocolException(e);
            }
        }
        return callBackend(target, request, context);
    }
View Full Code Here

        if (requestURI.isAbsolute()) {
            String host = requestURI.getHost();
            int port = requestURI.getPort();
            String scheme = requestURI.getScheme();
            if (host == null) {
                throw new ClientProtocolException(
                        "URI does not specify a valid host name: " + requestURI);
            }
            target = new HttpHost(host, port, scheme);
        }
        return target;
View Full Code Here

        }

        try {
            return director.execute(target, request, execContext);
        } catch(HttpException httpException) {
            throw new ClientProtocolException(httpException);
        }
    }
View Full Code Here

        URI requestURI = request.getURI();
        if (requestURI.isAbsolute()) {
            target = URIUtils.extractHost(requestURI);
            if (target == null) {
                throw new ClientProtocolException(
                        "URI does not specify a valid host name: " + requestURI);
            }
        }
        return target;
    }
View Full Code Here

TOP

Related Classes of org.apache.http.client.ClientProtocolException

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.