Java Code Examples for io.undertow.util.HeaderValues#peekFirst()
The following examples show how to use
io.undertow.util.HeaderValues#peekFirst() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HashSourceIpHostSelector.java From galeb with Apache License 2.0 | 5 votes |
private String getKey(final HttpServerExchange exchange) { String aSourceIP; String defaultSourceIp = "127.0.0.1"; String httpHeaderXrealIp = "X-Real-IP"; String httpHeaderXForwardedFor = "X-Forwarded-For"; if (exchange == null) { return defaultSourceIp; } if (ignoreXForwardedFor) { aSourceIP = exchange.getSourceAddress().getHostString(); } else { final HeaderValues headerXrealIp = exchange.getRequestHeaders().get(httpHeaderXrealIp); aSourceIP = headerXrealIp != null ? headerXrealIp.peekFirst() : null; if (aSourceIP != null) { return aSourceIP; } final HeaderValues headerXForwardedFor = exchange.getRequestHeaders().get(httpHeaderXForwardedFor); aSourceIP = headerXForwardedFor != null ? headerXForwardedFor.peekFirst() : null; if (aSourceIP != null) { return aSourceIP.contains(",") ? aSourceIP.split(",")[0] : aSourceIP; } aSourceIP = exchange.getSourceAddress().getHostString(); } return aSourceIP != null ? aSourceIP : defaultSourceIp; }
Example 2
Source File: HttpServerExchangeAdaptor.java From pinpoint with Apache License 2.0 | 5 votes |
@Override public String getHeader(HttpServerExchange request, String name) { final HeaderValues values = request.getRequestHeaders().get(name); if (values != null) { return values.peekFirst(); } return null; }
Example 3
Source File: CorsHandler.java From mangooio with Apache License 2.0 | 4 votes |
private String getOrigin(HttpServerExchange exchange) { HeaderValues headers = exchange.getRequestHeaders().get("Origin"); return headers == null ? null : headers.peekFirst(); }