use of org.httpkit.RequestTooLargeException in project http-kit by http-kit.
the class HttpServer method decodeHttp.
private void decodeHttp(HttpAtta atta, SelectionKey key, SocketChannel ch) {
try {
boolean sentContinue = false;
do {
AsyncChannel channel = atta.channel;
HttpRequest request = atta.decoder.decode(buffer);
if (request != null) {
channel.reset(request);
if (request.isWebSocket) {
key.attach(new WsAtta(channel, maxWs));
} else {
atta.keepalive = request.isKeepAlive;
}
request.channel = channel;
request.remoteAddr = (InetSocketAddress) ch.socket().getRemoteSocketAddress();
handler.handle(request, new RespCallback(key, this));
// pipelining not supported : need queue to ensure order
atta.decoder.reset();
} else if (!sentContinue && atta.decoder.requiresContinue()) {
tryWrite(key, HttpEncode(100, new HeaderMap(), null));
sentContinue = true;
}
} while (// consume all
buffer.hasRemaining());
} catch (ProtocolException e) {
closeKey(key, -1);
} catch (RequestTooLargeException e) {
atta.keepalive = false;
tryWrite(key, HttpEncode(413, new HeaderMap(), e.getMessage()));
} catch (LineTooLargeException e) {
// close after write
atta.keepalive = false;
tryWrite(key, HttpEncode(414, new HeaderMap(), e.getMessage()));
}
}
Aggregations