List of usage examples for io.netty.handler.codec.http HttpHeaders getHeader
@Deprecated public static String getHeader(HttpMessage message, CharSequence name)
From source file:com.soho.framework.server.servlet.impl.HttpServletRequestImpl.java
License:Apache License
@Override public Enumeration<Locale> getLocales() { Collection<Locale> locales = Utils.parseAcceptLanguageHeader( HttpHeaders.getHeader(this.originalRequest, HttpHeaders.Names.ACCEPT_LANGUAGE)); if (locales == null || locales.isEmpty()) { locales = new ArrayList<Locale>(); locales.add(Locale.getDefault()); }/*from ww w. j a v a2s. c om*/ return Utils.enumeration(locales); }
From source file:com.soho.framework.server.servlet.impl.HttpServletResponseImpl.java
License:Apache License
@Override public String getContentType() { return HttpHeaders.getHeader(this.originalResponse, HttpHeaders.Names.CONTENT_TYPE); }
From source file:com.soho.framework.server.servlet.impl.HttpServletResponseImpl.java
License:Apache License
@Override public String getCharacterEncoding() { return HttpHeaders.getHeader(this.originalResponse, Names.CONTENT_ENCODING); }
From source file:com.whizzosoftware.hobson.hub.websockets.Authorizer.java
License:Open Source License
@Override protected void channelRead0(ChannelHandlerContext ctx, FullHttpRequest message) throws Exception { logger.trace("channelRead0: {}", message); // attempt to get token from header and then from cookie String token = null;/*from ww w . j a va2 s . c o m*/ String h = HttpHeaders.getHeader(message, "Authorization"); if (h != null && h.startsWith("Bearer ") && h.length() > 7) { token = h.substring(7, h.length()).trim(); } else { h = HttpHeaders.getHeader(message, "Cookie"); if (h != null) { Set<Cookie> cookies = CookieDecoder.decode(h); if (cookies != null) { for (Cookie c : cookies) { if ("Token".equalsIgnoreCase(c.getName())) { token = c.getValue(); } } } } } // if we found a token, process the message if (token != null) { try { HobsonUser user = accessManager.authenticate(token); accessManager.authorize(user, AuthorizationAction.HUB_READ, null); if (user != null) { logger.trace("Found token, passing message along"); ctx.fireChannelRead(message.retain()); } } catch (Exception e) { logger.debug("Token decryption error", e); } } else { logger.debug("No token found; closing connection"); DefaultFullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.UNAUTHORIZED); response.headers().add("Content-Length", 0); ctx.writeAndFlush(response); ctx.close(); } }
From source file:io.reactivex.netty.protocol.http.client.HttpRequestHeaders.java
License:Apache License
public String getHeader(CharSequence name) { return HttpHeaders.getHeader(nettyRequest, name); }
From source file:io.reactivex.netty.protocol.http.client.HttpRequestHeaders.java
License:Apache License
public String getHeader(String name) { return HttpHeaders.getHeader(nettyRequest, name); }
From source file:io.reactivex.netty.protocol.http.client.HttpResponseHeaders.java
License:Apache License
public String getHeader(CharSequence name) { return HttpHeaders.getHeader(nettyResponse, name); }
From source file:io.reactivex.netty.protocol.http.client.HttpResponseHeaders.java
License:Apache License
public String getHeader(String name) { return HttpHeaders.getHeader(nettyResponse, name); }
From source file:io.scalecube.socketio.pipeline.PipelineUtils.java
License:Apache License
public static SocketAddress getHeaderClientIPParamValue(HttpMessage message, String paramName) { SocketAddress result = null;/*from w w w . ja va 2s . co m*/ if (paramName != null && !paramName.trim().isEmpty()) { String ip = null; try { ip = HttpHeaders.getHeader(message, paramName); if (ip != null) { result = new InetSocketAddress(InetAddress.getByName(ip), 0); } } catch (Exception e) { log.warn("Failed to parse IP address: {} from http header: {}", ip, paramName); } } return result; }
From source file:net.javaforge.netty.servlet.bridge.impl.HttpServletRequestImpl.java
License:Apache License
@Override public Enumeration getLocales() { Collection<Locale> locales = Utils.parseAcceptLanguageHeader( HttpHeaders.getHeader(this.originalRequest, HttpHeaders.Names.ACCEPT_LANGUAGE)); if (locales == null || locales.isEmpty()) { locales = new ArrayList<Locale>(); locales.add(Locale.getDefault()); }//from w w w. j a va2 s . co m return Utils.enumeration(locales); }