use of org.apache.flink.shaded.netty4.io.netty.handler.codec.TooLongFrameException in project nuls by nuls-io.
the class ClientChannelHandler method exceptionCaught.
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
if (!(cause instanceof IOException) && !(cause instanceof TooLongFrameException)) {
Attribute<Node> nodeAttribute = ctx.channel().attr(NodeAttributeKey.NODE_KEY);
Node node = nodeAttribute.get();
Log.error("----------------nodeId:" + node.getId());
Log.error(cause);
}
ctx.close();
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.TooLongFrameException in project vert.x by eclipse.
the class ServerConnection method processMessage.
private void processMessage(Object msg) {
if (msg instanceof HttpObject) {
HttpObject obj = (HttpObject) msg;
DecoderResult result = obj.decoderResult();
if (result.isFailure()) {
Throwable cause = result.cause();
if (cause instanceof TooLongFrameException) {
String causeMsg = cause.getMessage();
HttpVersion version;
if (msg instanceof HttpRequest) {
version = ((HttpRequest) msg).protocolVersion();
} else if (currentRequest != null) {
version = currentRequest.version() == io.vertx.core.http.HttpVersion.HTTP_1_0 ? HttpVersion.HTTP_1_0 : HttpVersion.HTTP_1_1;
} else {
version = HttpVersion.HTTP_1_1;
}
HttpResponseStatus status = causeMsg.startsWith("An HTTP line is larger than") ? HttpResponseStatus.REQUEST_URI_TOO_LONG : HttpResponseStatus.BAD_REQUEST;
DefaultFullHttpResponse resp = new DefaultFullHttpResponse(version, status);
writeToChannel(resp);
}
// That will close the connection as it is considered as unusable
channel.pipeline().fireExceptionCaught(result.cause());
return;
}
if (msg instanceof HttpRequest) {
HttpRequest request = (HttpRequest) msg;
if (server.options().isHandle100ContinueAutomatically()) {
if (HttpHeaders.is100ContinueExpected(request)) {
write100Continue();
}
}
HttpServerResponseImpl resp = new HttpServerResponseImpl(vertx, this, request);
HttpServerRequestImpl req = new HttpServerRequestImpl(this, request, resp);
handleRequest(req, resp);
}
if (msg instanceof HttpContent) {
HttpContent chunk = (HttpContent) msg;
if (chunk.content().isReadable()) {
Buffer buff = Buffer.buffer(chunk.content());
handleChunk(buff);
}
//TODO chunk trailers
if (msg instanceof LastHttpContent) {
if (!paused) {
handleEnd();
} else {
// Requeue
pending.add(LastHttpContent.EMPTY_LAST_CONTENT);
}
}
}
} else if (msg instanceof WebSocketFrameInternal) {
WebSocketFrameInternal frame = (WebSocketFrameInternal) msg;
handleWsFrame(frame);
}
checkNextTick();
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.TooLongFrameException in project vert.x by eclipse.
the class Http1xTest method testServerConnectionExceptionHandler.
@Test
public void testServerConnectionExceptionHandler() throws Exception {
server.connectionHandler(conn -> {
conn.exceptionHandler(err -> {
assertTrue(err instanceof TooLongFrameException);
testComplete();
});
});
server.requestHandler(req -> {
fail();
});
CountDownLatch listenLatch = new CountDownLatch(1);
server.listen(onSuccess(s -> listenLatch.countDown()));
awaitLatch(listenLatch);
HttpClientRequest req = client.post(DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, "/somepath", resp -> {
});
req.putHeader("the_header", TestUtils.randomAlphaString(10000));
req.sendHead();
await();
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.TooLongFrameException in project netty by netty.
the class StompSubframeDecoder method readLine.
private static String readLine(ByteBuf buffer, int maxLineLength) {
AppendableCharSequence buf = new AppendableCharSequence(128);
int lineLength = 0;
for (; ; ) {
byte nextByte = buffer.readByte();
if (nextByte == StompConstants.CR) {
nextByte = buffer.readByte();
if (nextByte == StompConstants.LF) {
return buf.toString();
}
} else if (nextByte == StompConstants.LF) {
return buf.toString();
} else {
if (lineLength >= maxLineLength) {
throw new TooLongFrameException("An STOMP line is larger than " + maxLineLength + " bytes.");
}
lineLength++;
buf.append((char) nextByte);
}
}
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.TooLongFrameException in project riposte by Nike-Inc.
the class BackstopperRiposteFrameworkErrorHandlerListenerTest method shouldHandleTooLongFrameExceptionAndAddCauseMetadata.
@Test
public void shouldHandleTooLongFrameExceptionAndAddCauseMetadata() {
ApiExceptionHandlerListenerResult result = listener.shouldHandleException(new TooLongFrameException());
assertThat(result.shouldHandleResponse).isTrue();
assertThat(result.errors).isEqualTo(singletonError(testProjectApiErrors.getMalformedRequestApiError()));
assertThat(result.errors.first().getMetadata().get("cause")).isEqualTo("The request exceeded the maximum payload size allowed");
}
Aggregations