Example usage for io.netty.handler.codec.http HttpHeaders addHeader

List of usage examples for io.netty.handler.codec.http HttpHeaders addHeader

Introduction

In this page you can find the example usage for io.netty.handler.codec.http HttpHeaders addHeader.

Prototype

@Deprecated
public static void addHeader(HttpMessage message, CharSequence name, Object value) 

Source Link

Usage

From source file:com.corundumstudio.socketio.handler.EncoderHandler.java

License:Apache License

private void write(XHROptionsMessage msg, ChannelHandlerContext ctx) {
    HttpResponse res = new DefaultHttpResponse(HTTP_1_1, HttpResponseStatus.OK);

    HttpHeaders.addHeader(res, "Set-Cookie", "io=" + msg.getSessionId());
    HttpHeaders.addHeader(res, CONNECTION, KEEP_ALIVE);
    HttpHeaders.addHeader(res, ACCESS_CONTROL_ALLOW_HEADERS, CONTENT_TYPE);
    addOriginHeaders(ctx.channel(), res);

    ByteBuf out = encoder.allocateBuffer(ctx.alloc());
    sendMessage(msg, ctx.channel(), out, res);
}

From source file:com.corundumstudio.socketio.handler.EncoderHandler.java

License:Apache License

private void addOriginHeaders(Channel channel, HttpResponse res) {
    if (version != null) {
        res.headers().add(HttpHeaders.Names.SERVER, version);
    }//www . j ava  2 s  . c  o  m

    if (configuration.getOrigin() != null) {
        HttpHeaders.addHeader(res, ACCESS_CONTROL_ALLOW_ORIGIN, configuration.getOrigin());
        HttpHeaders.addHeader(res, ACCESS_CONTROL_ALLOW_CREDENTIALS, Boolean.TRUE);
    } else {
        String origin = channel.attr(ORIGIN).get();
        if (origin != null) {
            HttpHeaders.addHeader(res, ACCESS_CONTROL_ALLOW_ORIGIN, origin);
            HttpHeaders.addHeader(res, ACCESS_CONTROL_ALLOW_CREDENTIALS, Boolean.TRUE);
        } else {
            HttpHeaders.addHeader(res, ACCESS_CONTROL_ALLOW_ORIGIN, "*");
        }
    }
}

From source file:com.corundumstudio.socketio.SocketIOEncoder.java

License:Apache License

private HttpResponse createHttpResponse(String origin, ByteBuf message) {
    HttpResponse res = new DefaultHttpResponse(HTTP_1_1, HttpResponseStatus.OK);

    HttpHeaders.addHeader(res, CONTENT_TYPE, "text/plain; charset=UTF-8");
    HttpHeaders.addHeader(res, CONNECTION, KEEP_ALIVE);
    if (origin != null) {
        HttpHeaders.addHeader(res, ACCESS_CONTROL_ALLOW_ORIGIN, origin);
        HttpHeaders.addHeader(res, ACCESS_CONTROL_ALLOW_CREDENTIALS, "true");
    }/* w w w .  java2  s .  c  o m*/
    HttpHeaders.setContentLength(res, message.readableBytes());

    return res;
}

From source file:com.cu.http.container.core.adaptor.NettyServletResponse.java

License:Apache License

public void addCookie(Cookie cookie) {
    HttpHeaders.addHeader(this.originalResponse, SET_COOKIE,
            ClientCookieEncoder.encode(cookie.getName(), cookie.getValue()));
}

From source file:com.cu.http.container.core.adaptor.NettyServletResponse.java

License:Apache License

public void addDateHeader(String name, long date) {
    HttpHeaders.addHeader(this.originalResponse, name, date);
}

From source file:com.cu.http.container.core.adaptor.NettyServletResponse.java

License:Apache License

public void addHeader(String name, String value) {
    HttpHeaders.addHeader(this.originalResponse, name, value);
}

From source file:com.ebay.jetstream.http.netty.server.DefaultHttpServletResponse.java

License:MIT License

@Override
public void addHeader(String arg0, String arg1) {
    HttpHeaders.addHeader(m_nettyhttpresp, arg0, arg1);

}

From source file:com.soho.framework.server.servlet.impl.HttpServletResponseImpl.java

License:Apache License

@Override
public void addCookie(Cookie cookie) {
    String result = ServerCookieEncoder
            .encode(new io.netty.handler.codec.http.DefaultCookie(cookie.getName(), cookie.getValue()));
    HttpHeaders.addHeader(this.originalResponse, SET_COOKIE, result);
}

From source file:com.soho.framework.server.servlet.impl.HttpServletResponseImpl.java

License:Apache License

@Override
public void addDateHeader(String name, long date) {
    HttpHeaders.addHeader(this.originalResponse, name, date);
}

From source file:com.soho.framework.server.servlet.impl.HttpServletResponseImpl.java

License:Apache License

@Override
public void addHeader(String name, String value) {
    HttpHeaders.addHeader(this.originalResponse, name, value);
}