Package org.apache.http

Examples of org.apache.http.HttpException


        if (response == null) {
            throw new IllegalArgumentException("HTTP response may not be null");
        }
        assertNotClosed();
        if (this.response != null) {
            throw new HttpException("Response already submitted");
        }
        this.responseWriter.write(response);
        this.hasBufferedOutput = this.outbuf.hasData();

        if (response.getStatusLine().getStatusCode() >= 200) {
View Full Code Here


        if (request == null) {
            throw new IllegalArgumentException("HTTP request may not be null");
        }
        assertNotClosed();
        if (this.request != null) {
            throw new HttpException("Request already submitted");
        }
        this.requestWriter.write(request);
        this.hasBufferedOutput = this.outbuf.hasData();

        if (request instanceof HttpEntityEnclosingRequest
View Full Code Here

            public Cancellable handle(
                    final HttpRequest request,
                    final HttpAsyncResponseTrigger trigger,
                    final HttpContext context) throws HttpException, IOException {
                throw new HttpException("Boom");
            }
View Full Code Here

            }
        } else {
            String s = request.getRequestLine().getUri();
            int idx = s.indexOf('x');
            if (idx == -1) {
                throw new HttpException("Unexpected request-URI format");
            }
            String pattern = s.substring(0, idx);
            int count = Integer.parseInt(s.substring(idx + 1, s.length()));

            StringBuilder buffer = new StringBuilder();
View Full Code Here

                    final NHttpResponseTrigger trigger,
                    final HttpContext context) throws HttpException, IOException {
                String s = request.getRequestLine().getUri();
                int idx = s.indexOf('x');
                if (idx == -1) {
                    throw new HttpException("Unexpected request-URI format");
                }
                String pattern = s.substring(0, idx);
                int count = Integer.parseInt(s.substring(idx + 1, s.length()));

                StringBuilder buffer = new StringBuilder();
View Full Code Here

            @Override
            public void handle(
                    final HttpRequest request,
                    final HttpResponse response,
                    final HttpContext context) throws HttpException, IOException {
                throw new HttpException(request.getRequestLine().getUri());
            }

        };

        NHttpRequestExecutionHandler requestExecutionHandler = new RequestExecutionHandler() {
View Full Code Here

                new Thread() {
                    @Override
                    public void run() {
                        try { Thread.sleep(10); } catch(InterruptedException ie) {}
                        trigger.handleException(
                                new HttpException(request.getRequestLine().getUri()));
                    }
                }.start();
            }

        };
View Full Code Here

        HttpExchange httpExchange = this.protocolHandler.new HttpExchange();
        httpExchange.setRequestState(MessageState.READY);
        httpExchange.setResponseState(MessageState.READY);
        this.connContext.setAttribute(HttpAsyncServiceHandler.HTTP_EXCHANGE, httpExchange);

        HttpException httpex = new HttpException();
        this.protocolHandler.exception(this.conn, httpex);

        Assert.assertEquals(MessageState.READY, httpExchange.getRequestState());
        Assert.assertEquals(MessageState.BODY_STREAM, httpExchange.getResponseState());
        Assert.assertNotNull(httpExchange.getResponseProducer());
View Full Code Here

        this.connContext.setAttribute(HttpAsyncServiceHandler.HTTP_EXCHANGE, httpExchange);

        Mockito.doThrow(new RuntimeException()).when(this.httpProcessor).process(
                Mockito.any(HttpResponse.class), Mockito.eq(exchangeContext));
        try {
            HttpException httpex = new HttpException();
            this.protocolHandler.exception(this.conn, httpex);
            Assert.fail("RuntimeException expected");
        } catch (RuntimeException ex) {
            Mockito.verify(this.conn).shutdown();
        }
View Full Code Here

        httpExchange.setResponseState(MessageState.READY);
        this.connContext.setAttribute(HttpAsyncServiceHandler.HTTP_EXCHANGE, httpExchange);

        Mockito.doThrow(new IOException()).when(this.httpProcessor).process(
                Mockito.any(HttpResponse.class), Mockito.eq(exchangeContext));
        HttpException httpex = new HttpException();

        this.protocolHandler.exception(this.conn, httpex);

        Mockito.verify(this.conn).shutdown();
    }
View Full Code Here

TOP

Related Classes of org.apache.http.HttpException

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.