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


Java HeaderValues.element方法代码示例

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


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

示例1: handleRequest

import io.undertow.util.HeaderValues; //导入方法依赖的package包/类
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
    String addr = exchange.getSourceAddress().getAddress().getHostAddress();

    List<String> locals = App.getConfig().getStringList("server.proxy.localhosts");
    for (String headerName : App.getConfig().getStringList("server.proxy.headers")) {
        if (locals.contains(addr)) {
            HeaderValues header = exchange.getRequestHeaders().get(headerName);
            if (header != null && !header.isEmpty()) {
                addr = header.element();
            }
        }
    }

    exchange.putAttachment(IP, addr);
    next.handleRequest(exchange);
}
 
开发者ID:xSke,项目名称:Pxls,代码行数:18,代码来源:IPReader.java

示例2: handleRequest

import io.undertow.util.HeaderValues; //导入方法依赖的package包/类
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
    Locale locale = Locale.forLanguageTag(this.config.getApplicationLanguage());
    Attachment attachment = exchange.getAttachment(RequestHelper.ATTACHMENT_KEY);

    Cookie i18nCookie = exchange.getRequestCookies().get(this.config.getI18nCookieName());
    if (i18nCookie == null) {
        final HeaderValues headerValues = exchange.getRequestHeaders().get(Header.ACCEPT_LANGUAGE.toHttpString());
        if (headerValues != null) {
            String acceptLanguage = headerValues.element();
            if (StringUtils.isNotBlank(acceptLanguage)) {
                locale = LocaleUtils.getLocaleFromString(acceptLanguage);
            }
        }
    } else {
        locale = LocaleUtils.getLocaleFromString(i18nCookie.getValue());
    }

    attachment.getMessages().reload(locale);
    attachment.withLocale(locale);
    
    exchange.putAttachment(RequestHelper.ATTACHMENT_KEY, attachment);
    nextHandler(exchange);
}
 
开发者ID:svenkubiak,项目名称:mangooio,代码行数:25,代码来源:LocaleHandler.java

示例3: connected

import io.undertow.util.HeaderValues; //导入方法依赖的package包/类
@Override
public void connected(ServerSentEventConnection connection, String lastEventId) {
    if (this.hasAuthentication) {
        String header = null;
        HeaderValues headerValues = connection.getRequestHeaders().get(Header.COOKIE.toHttpString());
        if (headerValues != null) {
            header = headerValues.element();
        }

        if (this.requestHelper.hasValidAuthentication(header)) {
            Application.getInstance(ServerSentEventService.class).addConnection(connection);
            connection.addCloseTask(Application.getInstance(ServerSentEventCloseListener.class));
        } else {
            IOUtils.closeQuietly(connection);
        }
    } else {
        Application.getInstance(ServerSentEventService.class).addConnection(connection);
        connection.addCloseTask(Application.getInstance(ServerSentEventCloseListener.class));
    }
}
 
开发者ID:svenkubiak,项目名称:mangooio,代码行数:21,代码来源:ServerSentEventHandler.java

示例4: getCacheKey

import io.undertow.util.HeaderValues; //导入方法依赖的package包/类
/**
 * Creates a key for used for limit an request containing the
 * requested url and the source host
 * 
 * @param exchange The HttpServerExchange
 * @return The key url + host
 */
private String getCacheKey(HttpServerExchange exchange) {
    String host = null;

    HeaderMap headerMap = exchange.getRequestHeaders();
    if (headerMap != null) {
        HeaderValues headerValues = headerMap.get(Header.X_FORWARDED_FOR.toHttpString());
        if (headerValues != null) {
            host = headerValues.element();
        }
    }
    
    if (StringUtils.isBlank(host)) {
        InetSocketAddress inetSocketAddress = exchange.getSourceAddress();
        if (inetSocketAddress != null) {
            host = inetSocketAddress.getHostString();
        }
    }
    
    if (StringUtils.isNotBlank(host)) {
        host = host.toLowerCase(Locale.ENGLISH);
    }
    
    String url = exchange.getRequestURL();
    if (StringUtils.isNotBlank(url)) {
        url = url.toLowerCase(Locale.ENGLISH);
    }
    
    return url + host;
}
 
开发者ID:svenkubiak,项目名称:mangooio,代码行数:37,代码来源:LimitHandler.java


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