Package org.apache.http.client

Examples of org.apache.http.client.ClientProtocolException


            }
            return revalidateCacheEntry(target, request, context, entry);
        } catch (final IOException ioex) {
            return handleRevalidationFailure(request, context, entry, now);
        } catch (final ProtocolException e) {
            throw new ClientProtocolException(e);
        }
    }
View Full Code Here


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

    }

    @Test
    public void testNonCompliantRequestWrapsAndReThrowsProtocolException() throws Exception {

        ClientProtocolException expected = new ClientProtocolException("ouch");

        requestIsFatallyNonCompliant(null);
        requestCannotBeMadeCompliantThrows(expected);

        boolean gotException = false;
View Full Code Here

            }
            return revalidateCacheEntry(target, request, context, entry);
        } catch (IOException ioex) {
            return handleRevalidationFailure(request, context, entry, now);
        } catch (ProtocolException e) {
            throw new ClientProtocolException(e);
        }
    }
View Full Code Here

            throws ClientProtocolException {
        RequestWrapper newRequest;
        try {
            newRequest = new RequestWrapper(request);
        } catch (ProtocolException pe) {
            throw new ClientProtocolException(pe);
        }
        newRequest.setProtocolVersion(version);

        return newRequest;
    }
View Full Code Here

            throws ClientProtocolException {
        RequestWrapper newRequest;
        try {
            newRequest = new RequestWrapper(request);
        } catch (ProtocolException pe) {
            throw new ClientProtocolException(pe);
        }
        newRequest.setProtocolVersion(version);

        return newRequest;
    }
View Full Code Here

                    throw new HttpResponseException(
                            statusLine.getStatusCode(),
                            statusLine.getReasonPhrase());
                }
                if (entity == null) {
                    throw new ClientProtocolException("Response contains no content");
                }
                DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
                try {
                    DocumentBuilder docBuilder = dbfac.newDocumentBuilder();
                    ContentType contentType = ContentType.getOrDefault(entity);
                    if (!contentType.equals(ContentType.APPLICATION_XML)) {
                        throw new ClientProtocolException("Unexpected content type:" + contentType);
                    }
                    String charset = contentType.getCharset();
                    if (charset == null) {
                        charset = HTTP.DEFAULT_CONTENT_CHARSET;
                    }
                    return docBuilder.parse(entity.getContent(), charset);
                } catch (ParserConfigurationException ex) {
                    throw new IllegalStateException(ex);
                } catch (SAXException ex) {
                    throw new ClientProtocolException("Malformed XML document", ex);
                }
            }

            });
        // Do something useful with the result
View Full Code Here

                for (int i = 0; i < this.count; i++) {
                    HttpResponse response = this.httpclient.execute(this.target, this.request);
                    int status = response.getStatusLine().getStatusCode();
                    if (status != 200) {
                        this.request.abort();
                        throw new ClientProtocolException("Unexpected status code: " + status);
                    }
                    EntityUtils.consume(response.getEntity());
                    Thread.sleep(10);
                }
            } catch (Exception ex) {
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

                return out;
            } else {
                return director.execute(target, request, execContext);
            }
        } catch(HttpException httpException) {
            throw new ClientProtocolException(httpException);
        }
    }
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.