Package org.apache.http.concurrent

Examples of org.apache.http.concurrent.Cancellable


        conn.getContext().setAttribute(HTTP_EXCHANGE, httpExchange);
    }

    public void closed(final NHttpServerConnection conn) {
        HttpExchange httpExchange = ensureNotNull(getHttpExchange(conn));
        Cancellable asyncProcess = httpExchange.getAsyncProcess();
        httpExchange.clear();
        if (asyncProcess != null) {
            asyncProcess.cancel();
        }
    }
View Full Code Here


                if (((HttpEntityEnclosingRequest) request).expectContinue()) {
                    httpExchange.setRequestState(MessageState.ACK_EXPECTED);
                    if (this.expectationVerifier != null) {
                        conn.suspendInput();
                        HttpAsyncContinueTrigger trigger = new ContinueTriggerImpl(httpExchange, conn);
                        Cancellable asyncProcess = this.expectationVerifier.verify(request, trigger, context);
                        httpExchange.setAsyncProcess(asyncProcess);
                    } else {
                        HttpResponse response = create100Continue(request);
                        conn.submitResponse(response);
                        httpExchange.setRequestState(MessageState.BODY_STREAM);
View Full Code Here

            conn.requestOutput();
        } else {
            Object result = consumer.getResult();
            HttpAsyncResponseTrigger trigger = new ResponseTriggerImpl(httpExchange, conn);
            try {
                Cancellable asyncProcess = handler.handle(result, trigger, context);
                httpExchange.setAsyncProcess(asyncProcess);
            } catch (HttpException ex) {
                HttpAsyncResponseProducer responseProducer = handleException(ex);
                httpExchange.setResponseProducer(responseProducer);
                conn.requestOutput();
View Full Code Here

    public void closed(final NHttpServerConnection conn) {
        final State state = getState(conn);
        if (state != null) {
            state.setTerminated();
            closeHandlers(state);
            final Cancellable cancellable = state.getCancellable();
            if (cancellable != null) {
                cancellable.cancel();
            }
            state.reset();
        }
    }
View Full Code Here

            final NHttpServerConnection conn, final Exception cause) {
        final State state = ensureNotNull(getState(conn));
        if (state != null) {
            state.setTerminated();
            closeHandlers(state, cause);
            final Cancellable cancellable = state.getCancellable();
            if (cancellable != null) {
                cancellable.cancel();
            }
            if (cause instanceof HttpException) {
                if (conn.isResponseSubmitted()
                        || state.getResponseState().compareTo(MessageState.INIT) > 0) {
                    // There is not much that we can do if a response
View Full Code Here

    @Test
    public void testHandleRequest() throws Exception {
        Mockito.when(this.request.getRequestLine()).thenReturn(new BasicRequestLine("GET", "/", HttpVersion.HTTP_1_0));

        Cancellable cancellable = this.asyncRequestHandler.handle(this.request, this.trigger, this.context);

        Assert.assertNull(cancellable);
        ArgumentCaptor<HttpResponse> argCaptor = ArgumentCaptor.forClass(HttpResponse.class);
        Mockito.verify(this.requestHandler).handle(
                Mockito.eq(this.request), argCaptor.capture(), Mockito.eq(this.context));
View Full Code Here

    @Test
    public void testHandleRequestUnsupportedVersion() throws Exception {
        Mockito.when(this.request.getRequestLine()).thenReturn(new BasicRequestLine("GET", "/", new HttpVersion(234, 456)));

        Cancellable cancellable = this.asyncRequestHandler.handle(this.request, this.trigger, this.context);

        Assert.assertNull(cancellable);
        ArgumentCaptor<HttpResponse> argCaptor = ArgumentCaptor.forClass(HttpResponse.class);
        Mockito.verify(this.requestHandler).handle(
                Mockito.eq(this.request), argCaptor.capture(), Mockito.eq(this.context));
View Full Code Here

        return this.uri;
    }

    public void abort() throws UnsupportedOperationException {
        if (this.aborted.compareAndSet(false, true)) {
            final Cancellable cancellable = this.cancellableRef.getAndSet(null);
            if (cancellable != null) {
                cancellable.cancel();
            }
        }
    }
View Full Code Here

        this.cancellableRef = new AtomicReference<Cancellable>(null);
    }

    @Deprecated
    public void setConnectionRequest(final ClientConnectionRequest connRequest) {
        setCancellable(new Cancellable() {

            public boolean cancel() {
                connRequest.abortRequest();
                return true;
            }
View Full Code Here

        });
    }

    @Deprecated
    public void setReleaseTrigger(final ConnectionReleaseTrigger releaseTrigger) {
        setCancellable(new Cancellable() {

            public boolean cancel() {
                try {
                    releaseTrigger.abortConnection();
                    return true;
View Full Code Here

TOP

Related Classes of org.apache.http.concurrent.Cancellable

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.