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

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

Introduction

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

Prototype

boolean contains(K name, V value);

Source Link

Document

Returns true if a header with the name and value exists, false otherwise.

Usage

From source file:io.vertx.core.http.impl.Http2ServerConnection.java

License:Open Source License

@Override
public synchronized void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers headers,
        int padding, boolean endOfStream) {
    VertxHttp2Stream stream = streams.get(streamId);
    if (stream == null) {
        if (isMalformedRequest(headers)) {
            handler.writeReset(streamId, Http2Error.PROTOCOL_ERROR.code());
            return;
        }//from ww  w  .j av a2s. c o m
        String contentEncoding = options.isCompressionSupported() ? HttpUtils.determineContentEncoding(headers)
                : null;
        Http2Stream s = handler.connection().stream(streamId);
        boolean writable = handler.encoder().flowController().isWritable(s);
        Http2ServerRequestImpl req = new Http2ServerRequestImpl(this, s, metrics, serverOrigin, headers,
                contentEncoding, writable);
        stream = req;
        CharSequence value = headers.get(HttpHeaderNames.EXPECT);
        if (options.isHandle100ContinueAutomatically()
                && ((value != null && HttpHeaderValues.CONTINUE.equals(value))
                        || headers.contains(HttpHeaderNames.EXPECT, HttpHeaderValues.CONTINUE))) {
            req.response().writeContinue();
        }
        streams.put(streamId, req);
        context.executeFromIO(() -> {
            Http2ServerResponseImpl resp = req.response();
            resp.beginRequest();
            requestHandler.handle(req);
            boolean hasPush = resp.endRequest();
            if (hasPush) {
                ctx.flush();
            }
        });
    } else {
        // Http server request trailer - not implemented yet (in api)
    }
    if (endOfStream) {
        context.executeFromIO(stream::onEnd);
    }
}