Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2016 The Netty Project
*
* The Netty Project licenses this file to you under the Apache License,
* version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at:
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package com.arangodb.shaded.netty.handler.codec.http2;
import com.arangodb.shaded.netty.buffer.ByteBufAllocator;
import com.arangodb.shaded.netty.buffer.Unpooled;
import com.arangodb.shaded.netty.channel.Channel;
import com.arangodb.shaded.netty.channel.ChannelHandler;
import com.arangodb.shaded.netty.channel.ChannelHandler.Sharable;
import com.arangodb.shaded.netty.channel.ChannelHandlerContext;
import com.arangodb.shaded.netty.handler.codec.EncoderException;
import com.arangodb.shaded.netty.handler.codec.MessageToMessageCodec;
import com.arangodb.shaded.netty.handler.codec.http.DefaultHttpContent;
import com.arangodb.shaded.netty.handler.codec.http.DefaultLastHttpContent;
import com.arangodb.shaded.netty.handler.codec.http.FullHttpMessage;
import com.arangodb.shaded.netty.handler.codec.http.FullHttpResponse;
import com.arangodb.shaded.netty.handler.codec.http.HttpContent;
import com.arangodb.shaded.netty.handler.codec.http.HttpHeaderNames;
import com.arangodb.shaded.netty.handler.codec.http.HttpHeaderValues;
import com.arangodb.shaded.netty.handler.codec.http.HttpMessage;
import com.arangodb.shaded.netty.handler.codec.http.HttpObject;
import com.arangodb.shaded.netty.handler.codec.http.HttpRequest;
import com.arangodb.shaded.netty.handler.codec.http.HttpResponse;
import com.arangodb.shaded.netty.handler.codec.http.HttpResponseStatus;
import com.arangodb.shaded.netty.handler.codec.http.HttpScheme;
import com.arangodb.shaded.netty.handler.codec.http.HttpStatusClass;
import com.arangodb.shaded.netty.handler.codec.http.HttpUtil;
import com.arangodb.shaded.netty.handler.codec.http.HttpVersion;
import com.arangodb.shaded.netty.handler.codec.http.LastHttpContent;
import com.arangodb.shaded.netty.handler.ssl.SslHandler;
import com.arangodb.shaded.netty.util.Attribute;
import com.arangodb.shaded.netty.util.AttributeKey;
import com.arangodb.shaded.netty.util.internal.UnstableApi;
import java.util.List;
/**
* This handler converts from {@link Http2StreamFrame} to {@link HttpObject},
* and back. It can be used as an adapter in conjunction with {@link
* Http2MultiplexCodec} to make http/2 connections backward-compatible with
* {@link ChannelHandler}s expecting {@link HttpObject}
*
* For simplicity, it converts to chunked encoding unless the entire stream
* is a single header.
*/
@UnstableApi
@Sharable
public class Http2StreamFrameToHttpObjectCodec extends MessageToMessageCodec {
private static final AttributeKey SCHEME_ATTR_KEY =
AttributeKey.valueOf(HttpScheme.class, "STREAMFRAMECODEC_SCHEME");
private final boolean isServer;
private final boolean validateHeaders;
public Http2StreamFrameToHttpObjectCodec(final boolean isServer,
final boolean validateHeaders) {
this.isServer = isServer;
this.validateHeaders = validateHeaders;
}
public Http2StreamFrameToHttpObjectCodec(final boolean isServer) {
this(isServer, true);
}
@Override
public boolean acceptInboundMessage(Object msg) throws Exception {
return msg instanceof Http2HeadersFrame || msg instanceof Http2DataFrame;
}
@Override
protected void decode(ChannelHandlerContext ctx, Http2StreamFrame frame, List