Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add simple logging about HttpResponseStatus.REQUEST_ENTITY_TOO_LARGE #59

Merged
merged 1 commit into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/java/com/teragrep/lsh_01/HttpInitializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
package com.teragrep.lsh_01;

import com.teragrep.lsh_01.config.InternalEndpointUrlConfig;
import com.teragrep.lsh_01.util.LoggingHttpObjectAggregator;
import com.teragrep.lsh_01.util.SslHandlerProvider;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpContentDecompressor;
import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.codec.http.HttpResponseStatus;
import io.netty.handler.codec.http.HttpServerCodec;
import io.netty.handler.ssl.SslHandler;
Expand Down Expand Up @@ -67,7 +67,7 @@ protected void initChannel(SocketChannel socketChannel) throws Exception {
}
pipeline.addLast(new HttpServerCodec());
pipeline.addLast(new HttpContentDecompressor());
pipeline.addLast(new HttpObjectAggregator(maxContentLength));
pipeline.addLast(new LoggingHttpObjectAggregator(maxContentLength));
pipeline
.addLast(
new HttpServerHandler(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
logstash-http-input to syslog bridge
Copyright 2024 Suomen Kanuuna Oy

Derivative Work of Elasticsearch
Copyright 2012-2015 Elasticsearch

Licensed 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

http://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.teragrep.lsh_01.util;

import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.HttpMessage;
import io.netty.handler.codec.http.HttpObjectAggregator;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public class LoggingHttpObjectAggregator extends HttpObjectAggregator {

private static final Logger LOGGER = LogManager.getLogger(LoggingHttpObjectAggregator.class);

public LoggingHttpObjectAggregator(int maxContentLength) {
super(maxContentLength);
}

public LoggingHttpObjectAggregator(int maxContentLength, boolean closeOnExpectationFailed) {
super(maxContentLength, closeOnExpectationFailed);
}

@Override
protected void handleOversizedMessage(ChannelHandlerContext ctx, HttpMessage oversized) throws Exception {
LOGGER.warn("Oversized HTTP message received, exceeds maxContentLength <{}>", maxContentLength());
super.handleOversizedMessage(ctx, oversized);
}

}