Skip to content
Open
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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2025 Contributors to the Eclipse Foundation
* Copyright (c) 2021, 2026 Contributors to the Eclipse Foundation
* Copyright (c) 2007, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -60,6 +60,7 @@
import org.glassfish.hk2.utilities.BuilderHelper;
import org.glassfish.hk2.utilities.ServiceLocatorUtilities;
import org.glassfish.internal.grizzly.V3Mapper;
import org.glassfish.kernel.KernelLoggerInfo;
import org.jvnet.hk2.config.types.Property;

public class GlassfishNetworkListener extends GenericGrizzlyListener {
Expand Down Expand Up @@ -401,10 +402,19 @@ protected boolean onHttpHeaderParsed(final HttpHeader httpHeader,
final Buffer buffer,
final FilterChainContext ctx) {

final boolean result = super.onHttpHeaderParsed(httpHeader,
boolean result = super.onHttpHeaderParsed(httpHeader,
buffer, ctx);

final HttpRequestPacket request = (HttpRequestPacket) httpHeader;

// Here we can add extra validation to prevent Http Server invalid use of headers
if (request.containsHeader(Header.ContentLength) && request.containsHeader(Header.TransferEncoding)) {
KernelLoggerInfo.getLogger().log(Level.SEVERE,
"Can't use both headers Content-Length and Transfer-Encoding from the same request");
request.getProcessingState().setError(true);
result = true;
}

final HttpResponsePacket response = request.getResponse();

// Set response "Server" header
Expand Down
Loading