Example usage for io.netty.handler.codec.http2 Http2Headers getAllAndRemove

List of usage examples for io.netty.handler.codec.http2 Http2Headers getAllAndRemove

Introduction

In this page you can find the example usage for io.netty.handler.codec.http2 Http2Headers getAllAndRemove.

Prototype

List<V> getAllAndRemove(K name);

Source Link

Document

Returns all values for the header with the specified name and removes them from this object.

Usage

From source file:com.linecorp.armeria.internal.ArmeriaHttpUtil.java

License:Apache License

/**
 * Converts the specified Armeria HTTP/2 headers into Netty HTTP/2 headers.
 *//*from  w w w .  ja v a  2 s  .  c  o m*/
public static Http2Headers toNettyHttp2(HttpHeaders in) {
    final Http2Headers out = new DefaultHttp2Headers(false, in.size());
    out.set(in);
    out.remove(HttpHeaderNames.CONNECTION);
    out.remove(HttpHeaderNames.TRANSFER_ENCODING);
    out.remove(HttpHeaderNames.TRAILER);

    if (!out.contains(HttpHeaderNames.COOKIE)) {
        return out;
    }

    // Split up cookies to allow for better compression.
    // https://tools.ietf.org/html/rfc7540#section-8.1.2.5
    final List<CharSequence> cookies = out.getAllAndRemove(HttpHeaderNames.COOKIE);
    for (CharSequence c : cookies) {
        out.add(HttpHeaderNames.COOKIE, COOKIE_SPLITTER.split(c));
    }

    return out;
}