Package org.asynchttpclient.uri

Examples of org.asynchttpclient.uri.Uri


    private static String computeRealmURI(Realm realm) {
        if (realm.isTargetProxy()) {
            return "/";
        } else {
            Uri uri = realm.getUri();
            if (realm.isUseAbsoluteURI()) {
                return realm.isOmitQuery() && MiscUtils.isNonEmpty(uri.getQuery()) ? uri.withNewQuery(null).toUrl() : uri.toUrl();
            } else {
                String path = getNonEmptyPath(uri);
                return realm.isOmitQuery() || !MiscUtils.isNonEmpty(uri.getQuery()) ? path : path + "?" + uri.getQuery();
            }
        }
    }
View Full Code Here


            // Disable SSL for the time being...
            ctx.notifyDownstream(new SSLSwitchingEvent(false, ctx.getConnection()));
            ctx.suspend();
            TunnelRequestEvent tunnelRequestEvent = (TunnelRequestEvent) event;
            final ProxyServer proxyServer = tunnelRequestEvent.getProxyServer();
            final Uri requestUri = tunnelRequestEvent.getUri();

            RequestBuilder builder = new RequestBuilder();
            builder.setMethod(Method.CONNECT.getMethodString());
            builder.setUrl("http://" + getAuthority(requestUri));
            Request request = builder.build();
View Full Code Here

        if (checkProxyAuthFailure(ctx, httpTxContext)) {
            return true;
        }

        final Request request = httpTxContext.getRequest();
        final Uri uri = request.getUri();
        boolean secure = Utils.isSecure(uri);
        boolean isWebSocket = isWSRequest(httpTxContext.getRequestUri());

        // If the request is secure, check to see if an error occurred during
        // the handshake. We have to do this here, as the error would occur
        // out of the scope of a HttpTxContext so there would be
        // no good way to communicate the problem to the caller.
        if (secure && checkHandshakeError(ctx, httpTxContext)) {
            return true;
        }

       
        if (isUpgradeRequest(httpTxContext.getHandler()) && isWebSocket) {
            httpTxContext.setWSRequest(true);
            convertToUpgradeRequest(httpTxContext);
        }

        HttpRequestPacket requestPacket = requestCache.poll();
        if (requestPacket == null) {
            requestPacket = new HttpRequestPacketImpl();
        }
       
        final Method method = Method.valueOf(request.getMethod());
       
        requestPacket.setMethod(method);
        requestPacket.setProtocol(Protocol.HTTP_1_1);

        // Special handling for CONNECT.
        if (method == Method.CONNECT) {
            final int port = uri.getPort();
            requestPacket.setRequestURI(uri.getHost() + ':' + (port == -1 ? 443 : port));
        } else if ((secure || isWebSocket) && config.isUseRelativeURIsWithConnectProxies()) {
            requestPacket.setRequestURI(getNonEmptyPath(uri));
        } else {
            requestPacket.setRequestURI(uri.toUrl());
        }

        final BodyHandler bodyHandler = isPayloadAllowed(method) ?
                bodyHandlerFactory.getBodyHandler(request) :
                null;
View Full Code Here

        return requestUri.getScheme().startsWith("ws");
    }

    private static void convertToUpgradeRequest(final HttpTxContext ctx) {
       
        final Uri requestUri = ctx.getRequestUri();

        ctx.setWsRequestURI(requestUri);
        ctx.setRequestUri(requestUri.withNewScheme(
                "ws".equals(requestUri.getScheme())
                        ? "http"
                        : "https"));
    }
View Full Code Here

        final String redirectURL = responsePacket.getHeader(Header.Location);
        if (redirectURL == null) {
            throw new IllegalStateException("redirect received, but no location header was present");
        }

        Uri orig;
        if (httpTransactionContext.getLastRedirectURI() == null) {
            orig = httpTransactionContext.getRequest().getUri();
        } else {
            orig = Uri.create(httpTransactionContext.getRequest().getUri(),
                    httpTransactionContext.getLastRedirectURI());
        }
        httpTransactionContext.setLastRedirectURI(redirectURL);
        Request requestToSend;
        Uri uri = Uri.create(orig, redirectURL);
        if (!uri.toUrl().equalsIgnoreCase(orig.toUrl())) {
            requestToSend = EventHandler.newRequest(uri, responsePacket, httpTransactionContext,
                    sendAsGet(responsePacket, httpTransactionContext));
        } else {
            httpTransactionContext.setStatusHandler(null);
            httpTransactionContext.setInvocationStatus(CONTINUE);
View Full Code Here

            final GrizzlyResponseFuture requestFuture,//
            CompletionHandler<Connection> completionHandler) throws IOException {
        final EndpointKey<SocketAddress> key = getEndPointKey(request, requestFuture.getProxyServer());
       
        final HostnameVerifier verifier = getVerifier();
        final Uri uri = request.getUri();
       
        if (Utils.isSecure(uri) && verifier != null) {
            completionHandler =
                    SwitchingSSLFilter.wrapWithHostnameVerifierHandler(
                            completionHandler, verifier, uri.getHost());
        }
       
        if (asyncConnect) {
            connectionPool.take(key, completionHandler);
        } else {
View Full Code Here

        }
        return key;
    }

    private SocketAddress getRemoteAddress(final Request request, final ProxyServer proxyServer) {
        final Uri requestUri = request.getUri();
        final String host = ((proxyServer != null) ? proxyServer.getHost() : requestUri.getHost());
        final int port = ((proxyServer != null) ? proxyServer.getPort() : requestUri.getPort());
        return new InetSocketAddress(host, getPort(request.getUri(), port));
    }
View Full Code Here

                // We must allow 401 handling again.
                future.getAndSetAuth(false);

                HttpHeaders responseHeaders = response.headers();
                String location = responseHeaders.get(HttpHeaders.Names.LOCATION);
                Uri uri = Uri.create(future.getUri(), location);

                if (!uri.equals(future.getUri())) {
                    final RequestBuilder requestBuilder = new RequestBuilder(future.getRequest());

                    if (!config.isRemoveQueryParamOnRedirect())
                        requestBuilder.addQueryParams(future.getRequest().getQueryParams());

                    // if we are to strictly handle 302, we should keep the original method (which browsers don't)
                    // 303 must force GET
                    if ((statusCode == FOUND.code() && !config.isStrict302Handling()) || statusCode == SEE_OTHER.code())
                        requestBuilder.setMethod("GET");

                    // in case of a redirect from HTTP to HTTPS, future attributes might change
                    final boolean initialConnectionKeepAlive = future.isKeepAlive();
                    final String initialPoolKey = channelManager.getPartitionId(future);

                    future.setUri(uri);
                    String newUrl = uri.toUrl();
                    if (request.getUri().getScheme().startsWith(WEBSOCKET)) {
                        newUrl = newUrl.replaceFirst(HTTP, WEBSOCKET);
                    }

                    logger.debug("Redirecting to {}", newUrl);
View Full Code Here

            boolean reclaimCache) throws IOException {

        if (closed.get())
            throw new IOException("Closed");

        Uri uri = request.getUri();

        // FIXME really useful? Why not do this check when building the request?
        if (uri.getScheme().startsWith(WEBSOCKET) && !validateWebSocketRequest(request, asyncHandler))
            throw new IOException("WebSocket method must be a GET");

        ProxyServer proxyServer = getProxyServer(config, request);
        boolean resultOfAConnect = future != null && future.getNettyRequest() != null && future.getNettyRequest().getHttpRequest().getMethod() == HttpMethod.CONNECT;
        boolean useProxy = proxyServer != null && !resultOfAConnect;
View Full Code Here

    }

    private Realm kerberosChallenge(Channel channel, List<String> proxyAuth, Request request, ProxyServer proxyServer, FluentCaseInsensitiveStringsMap headers, Realm realm,
            NettyResponseFuture<?> future, boolean proxyInd) throws NTLMEngineException {

        Uri uri = request.getUri();
        String host = request.getVirtualHost() == null ? uri.getHost() : request.getVirtualHost();
        String server = proxyServer == null ? host : proxyServer.getHost();
        try {
            String challengeHeader = SpnegoEngine.instance().generateToken(server);
            headers.remove(HttpHeaders.Names.AUTHORIZATION);
            headers.add(HttpHeaders.Names.AUTHORIZATION, "Negotiate " + challengeHeader);
View Full Code Here

TOP

Related Classes of org.asynchttpclient.uri.Uri

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.