当前位置: 首页>>代码示例>>Java>>正文


Java HttpServerExchange.getRequestURI方法代码示例

本文整理汇总了Java中io.undertow.server.HttpServerExchange.getRequestURI方法的典型用法代码示例。如果您正苦于以下问题:Java HttpServerExchange.getRequestURI方法的具体用法?Java HttpServerExchange.getRequestURI怎么用?Java HttpServerExchange.getRequestURI使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.undertow.server.HttpServerExchange的用法示例。


在下文中一共展示了HttpServerExchange.getRequestURI方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRedirectURI

import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
protected URI getRedirectURI(HttpServerExchange exchange, int port) throws URISyntaxException {
    String host = exchange.getHostName();

    String queryString = exchange.getQueryString();
    return new URI("https", null, host, port, exchange.getRequestURI(),
            queryString == null || queryString.length() == 0 ? null : queryString, null);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:SinglePortConfidentialityHandler.java

示例2: reservationCheck

import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
protected boolean reservationCheck(HttpServerExchange exchange) {
    HeaderMap requestHeaders = exchange.getRequestHeaders();
    String origin = requestHeaders.getFirst(CorsHeaders.ORIGIN);
    if (cors.getAllowedOrigins().contains("*") || cors.getAllowedOrigins().contains(origin)) {
        HeaderMap responseHeaders = exchange.getResponseHeaders();
        responseHeaders.put(new HttpString(CorsHeaders.ACCESS_CONTROL_ALLOW_ORIGIN), origin);

        String value = requestHeaders.getFirst(CorsHeaders.ACCESS_CONTROL_REQUEST_HEADERS);
        if (value != null) {
            responseHeaders.put(new HttpString(CorsHeaders.ACCESS_CONTROL_ALLOW_HEADERS), value);
        }

        value = requestHeaders.getFirst(CorsHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS);
        if (value != null) {
            responseHeaders.put(new HttpString(CorsHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS), value);
        }

        value = requestHeaders.getFirst(CorsHeaders.ACCESS_CONTROL_REQUEST_METHOD);
        if (value != null) {
            responseHeaders.put(new HttpString(CorsHeaders.ACCESS_CONTROL_ALLOW_METHODS), value);
        }
    }

    String uri = exchange.getRequestURI();
    if (uri.indexOf(path + "/") != 0) {
        exchange.setStatusCode(404);
        return false;
    }

    final String subscriptionId = uri.substring(path.length() + 1);
    if (subscriptionId.isEmpty()) {
        exchange.setStatusCode(404);
        return false;
    }

    EventReservationsHandler.Reservation reservation = eventReservationsHandler.existsReservation(subscriptionId);
    if (reservation == null) {
        exchange.setStatusCode(404);
        return false;
    }
    return true;
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:43,代码来源:EventBusToServerSentEvents.java

示例3: readAttribute

import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
@Override
public String readAttribute(final HttpServerExchange exchange) {
    return exchange.getRequestURI();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:RequestURLAttribute.java

示例4: getConnection

import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
@Override
public void getConnection(ProxyTarget target, HttpServerExchange exchange, ProxyCallback<ProxyConnection> callback, long timeout, TimeUnit timeUnit) {
    Realm realm = realmCache.matches(exchange.getRequestPath());
    if (realm != null) {
        parseToken(exchange).ifPresent(token -> {
            Optional<UserPermissionPrincipal> principal = authenticate(realm.getId(), token);

            principal.ifPresent(p -> {
                Map<String, Object> body = new HashMap<>();
                body.put("sub", p.getName());
                body.put("permissions", p.getPermissions());
                p.getProfiles().forEach((k, v) -> {
                    body.put(k, v);
                });
                exchange.getRequestHeaders().put(HttpString.tryFromString(config.getBackendHeaderName()),
                        jwt.sign(body, jwtHeader, null));
            });
        });
    } else {
        exchange.setStatusCode(404);
        exchange.endExchange();
        return;
    }

    Application application = realmCache.getApplication(realm);
    ClientConnection existing = exchange.getConnection().getAttachment(clientAttachmentKey);
    if (existing != null) {
        if (existing.isOpen()) {
            //this connection already has a client, re-use it
            String path = exchange.getRequestURI();
            if (path.startsWith(application.getVirtualPath())) {
                String passTo = calculatePathTo(path, application);
                exchange.setRequestPath(passTo);
                exchange.setRequestURI(passTo);
            }
            callback.completed(exchange, new ProxyConnection(existing, "/"));
            return;
        } else {
            exchange.getConnection().removeAttachment(clientAttachmentKey);
        }
    }

    try {
        URI uri = application.getUriToPass();
        client.connect(new ConnectNotifier(callback, exchange),
                new URI(uri.getScheme(), /*userInfo*/null, uri.getHost(), uri.getPort(),
                        /*path*/null, /*query*/null, /*fragment*/null),
                exchange.getIoThread(),
                exchange.getConnection().getByteBufferPool(), OptionMap.EMPTY);
    } catch (URISyntaxException e) {
        throw new MisconfigurationException("", application.getUriToPass(), e);
    }
}
 
开发者ID:kawasima,项目名称:bouncr,代码行数:54,代码来源:MultiAppProxyClient.java


注:本文中的io.undertow.server.HttpServerExchange.getRequestURI方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。