Package com.facebook.presto.jdbc.internal.jetty.client.api

Examples of com.facebook.presto.jdbc.internal.jetty.client.api.Request


        }
    }

    public void send(HttpExchange exchange)
    {
        Request request = exchange.getRequest();
        Throwable cause = request.getAbortCause();
        if (cause != null)
        {
            exchange.abort(cause);
        }
        else
        {
            if (!queuedToBegin(request))
                throw new IllegalStateException();

            ContentProvider contentProvider = request.getContent();
            HttpContent content = this.content = new HttpContent(contentProvider);

            SenderState newSenderState = SenderState.SENDING;
            if (expects100Continue(request))
                newSenderState = content.hasContent() ? SenderState.EXPECTING_WITH_CONTENT : SenderState.EXPECTING;
View Full Code Here


                // with respect to concurrency between request and response.
                Result result = exchange.terminateRequest(null);

                // It is important to notify completion *after* we reset because
                // the notification may trigger another request/response
                Request request = exchange.getRequest();
                LOG.debug("Request success {}", request);
                HttpDestination destination = getHttpChannel().getHttpDestination();
                destination.getRequestNotifier().notifySuccess(exchange.getRequest());

                if (result != null)
View Full Code Here

        // Mark atomically the request as terminated and failed,
        // with respect to concurrency between request and response.
        Result result = exchange.terminateRequest(failure);

        Request request = exchange.getRequest();
        LOG.debug("Request failure {} {}", exchange, failure);
        HttpDestination destination = getHttpChannel().getHttpDestination();
        destination.getRequestNotifier().notifyFailure(request, failure);

        boolean notCommitted = isBeforeCommit(requestState);
        if (result == null && notCommitted && request.getAbortCause() == null)
        {
            // Complete the response from here
            if (exchange.responseComplete())
            {
                result = exchange.terminateResponse(failure);
View Full Code Here

        {
            HttpExchange exchange = getHttpExchange();
            if (exchange == null)
                return;

            Request request = exchange.getRequest();
            if (!headersToCommit(request))
                return;

            HttpContent content = HttpSender.this.content;
View Full Code Here

        {
            HttpExchange exchange = getHttpExchange();
            if (exchange == null)
                return Action.IDLE;

            Request request = exchange.getRequest();
            HttpContent content = HttpSender.this.content;

            ByteBuffer contentBuffer = content.getContent();
            if (contentBuffer != null)
            {
View Full Code Here

        return newHttpRequest(newConversation(), uri);
    }

    protected Request copyRequest(HttpRequest oldRequest, URI newURI)
    {
        Request newRequest = newHttpRequest(oldRequest.getConversation(), newURI);
        newRequest.method(oldRequest.getMethod())
                .version(oldRequest.getVersion())
                .content(oldRequest.getContent())
                .idleTimeout(oldRequest.getIdleTimeout(), TimeUnit.MILLISECONDS)
                .timeout(oldRequest.getTimeout(), TimeUnit.MILLISECONDS)
                .followRedirects(oldRequest.isFollowRedirects());
        for (HttpField header : oldRequest.getHeaders())
        {
            // We have a new URI, so skip the host header if present
            if (HttpHeader.HOST == header.getHeader())
                continue;

            // Remove expectation headers
            if (HttpHeader.EXPECT == header.getHeader())
                continue;

            // Remove cookies
            if (HttpHeader.COOKIE == header.getHeader())
                continue;

            // Remove authorization headers
            if (HttpHeader.AUTHORIZATION == header.getHeader() ||
                    HttpHeader.PROXY_AUTHORIZATION == header.getHeader())
                continue;

            newRequest.header(header.getName(), header.getValue());
        }
        return newRequest;
    }
View Full Code Here

     */
    public Result redirect(Request request, Response response) throws InterruptedException, ExecutionException
    {
        final AtomicReference<Result> resultRef = new AtomicReference<>();
        final CountDownLatch latch = new CountDownLatch(1);
        Request redirect = redirect(request, response, new BufferingResponseListener()
        {
            @Override
            public void onComplete(Result result)
            {
                resultRef.set(new Result(result.getRequest(),
                        result.getRequestFailure(),
                        new HttpContentResponse(result.getResponse(), getContent(), getEncoding()),
                        result.getResponseFailure()));
                latch.countDown();
            }
        });

        try
        {
            latch.await();
            Result result = resultRef.get();
            if (result.isFailed())
                throw new ExecutionException(result.getFailure());
            return result;
        }
        catch (InterruptedException x)
        {
            // If the application interrupts, we need to abort the redirect
            redirect.abort(x);
            throw x;
        }
    }
View Full Code Here

        {
            ++redirects;
            if (conversation != null)
                conversation.setAttribute(ATTRIBUTE, redirects);

            Request redirect = client.copyRequest(httpRequest, location);

            // Use given method
            redirect.method(method);

            redirect.onRequestBegin(new Request.BeginListener()
            {
                @Override
                public void onBegin(Request redirect)
                {
                    Throwable cause = request.getAbortCause();
                    if (cause != null)
                        redirect.abort(cause);
                }
            });

            redirect.send(listener);
            return redirect;
        }
        else
        {
            fail(request, response, new HttpResponseException("Max redirects exceeded " + redirects, response));
View Full Code Here

                return;
            }

            conversation.setAttribute(AUTHENTICATION_ATTRIBUTE, true);

            Request newRequest = client.copyRequest(request, request.getURI());
            authnResult.apply(newRequest);
            newRequest.onResponseSuccess(new Response.SuccessListener()
            {
                @Override
                public void onSuccess(Response response)
                {
                    client.getAuthenticationStore().addAuthenticationResult(authnResult);
View Full Code Here

        final HttpExchange exchange = getHttpExchanges().poll();
        LOG.debug("Processing {} on {}", exchange, connection);
        if (exchange == null)
            return false;

        final Request request = exchange.getRequest();
        Throwable cause = request.getAbortCause();
        if (cause != null)
        {
            // If we have a non-null abort cause, it means that someone
            // else has already aborted and notified, nothing do to here.
            LOG.debug("Aborted before processing {}: {}", exchange, cause);
View Full Code Here

TOP

Related Classes of com.facebook.presto.jdbc.internal.jetty.client.api.Request

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.