Http2RequestHandler.java — netty Source File
Architecture documentation for Http2RequestHandler.java, a java file in the netty codebase.
Entity Profile
Relationship Graph
Source Code
/*
* Copyright 2015 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 io.netty.example.http2.tiles;
import static io.netty.buffer.Unpooled.EMPTY_BUFFER;
import static io.netty.example.http2.Http2ExampleUtil.firstValue;
import static io.netty.example.http2.Http2ExampleUtil.toInt;
import static io.netty.handler.codec.http.HttpHeaderNames.CONTENT_TYPE;
import static io.netty.handler.codec.http.HttpUtil.setContentLength;
import static io.netty.handler.codec.http.HttpResponseStatus.BAD_REQUEST;
import static io.netty.handler.codec.http.HttpResponseStatus.OK;
import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1;
import static java.lang.Integer.parseInt;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.handler.codec.http.DefaultFullHttpResponse;
import io.netty.handler.codec.http.FullHttpRequest;
import io.netty.handler.codec.http.FullHttpResponse;
import io.netty.handler.codec.http.QueryStringDecoder;
import io.netty.handler.codec.http2.HttpConversionUtil;
import io.netty.handler.codec.http2.InboundHttp2ToHttpAdapter;
import java.util.concurrent.TimeUnit;
/**
* Handles all the requests for data. It receives a {@link FullHttpRequest},
* which has been converted by a {@link InboundHttp2ToHttpAdapter} before it
* arrived here. For further details, check {@link Http2OrHttpHandler} where the
* pipeline is setup.
*/
public class Http2RequestHandler extends SimpleChannelInboundHandler<FullHttpRequest> {
private static final String LATENCY_FIELD_NAME = "latency";
private static final int MIN_LATENCY = 0;
private static final int MAX_LATENCY = 1000;
private static final String IMAGE_COORDINATE_Y = "y";
private static final String IMAGE_COORDINATE_X = "x";
@Override
protected void channelRead0(ChannelHandlerContext ctx, FullHttpRequest request) throws Exception {
QueryStringDecoder queryString = new QueryStringDecoder(request.uri());
String streamId = streamId(request);
int latency = toInt(firstValue(queryString, LATENCY_FIELD_NAME), 0);
if (latency < MIN_LATENCY || latency > MAX_LATENCY) {
sendBadRequest(ctx, streamId);
// ... (63 more lines)
Domain
Subdomains
Classes
Source
Frequently Asked Questions
What does Http2RequestHandler.java do?
Http2RequestHandler.java is a source file in the netty codebase, written in java. It belongs to the Buffer domain, Search subdomain.
Where is Http2RequestHandler.java in the architecture?
Http2RequestHandler.java is located at example/src/main/java/io/netty/example/http2/tiles/Http2RequestHandler.java (domain: Buffer, subdomain: Search, directory: example/src/main/java/io/netty/example/http2/tiles).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free