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

Enable Netty HTTP header validation #2630

Merged
merged 2 commits into from
Sep 30, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ protected void handleCustomEndpoint(
Long start = System.currentTimeMillis();
FullHttpResponse rsp =
new DefaultFullHttpResponse(
HttpVersion.HTTP_1_1, HttpResponseStatus.OK, false);
HttpVersion.HTTP_1_1, HttpResponseStatus.OK, true);
try {
run(endpoint, req, rsp, decoder, req.method().toString());
NettyUtils.sendHttpResponse(ctx, rsp, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ private void responseDescribe(
(statusPhrase == null)
? HttpResponseStatus.valueOf(statusCode)
: new HttpResponseStatus(statusCode, statusPhrase);
FullHttpResponse resp =
new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, status, false);
FullHttpResponse resp = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, status, true);

if (contentType != null && contentType.length() > 0) {
resp.headers().set(HttpHeaderNames.CONTENT_TYPE, contentType);
Expand Down Expand Up @@ -148,10 +147,10 @@ private void responseInference(
HttpResponse resp;

if (responseHeaders != null && responseHeaders.containsKey(TS_STREAM_NEXT)) {
resp = new DefaultHttpResponse(HttpVersion.HTTP_1_1, status, false);
resp = new DefaultHttpResponse(HttpVersion.HTTP_1_1, status, true);
numStreams = responseHeaders.get(TS_STREAM_NEXT).equals("true") ? numStreams + 1 : -1;
} else {
resp = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, status, false);
resp = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, status, true);
}

if (contentType != null && contentType.length() > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public static void sendJsonResponse(ChannelHandlerContext ctx, String json) {

public static void sendJsonResponse(
ChannelHandlerContext ctx, String json, HttpResponseStatus status) {
FullHttpResponse resp = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, status, false);
FullHttpResponse resp = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, status, true);
resp.headers().set(HttpHeaderNames.CONTENT_TYPE, HttpHeaderValues.APPLICATION_JSON);
ByteBuf content = resp.content();
content.writeCharSequence(json, CharsetUtil.UTF_8);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ public void predict(ChannelHandlerContext ctx, String wfName, RequestInput input
new DefaultFullHttpResponse(
HttpVersion.HTTP_1_1,
HttpResponseStatus.OK,
false);
true);
resp.headers()
.set(
HttpHeaderNames.CONTENT_TYPE,
Expand Down
Loading