Skip to content

Feature/strict crlf for chunked transfer coding - #2220

Merged
OndroMih merged 5 commits into
eclipse-ee4j:mainfrom
carryel:feature/strict-CRLF-for-chunked-transfer-coding
Jun 2, 2025
Merged

Feature/strict crlf for chunked transfer coding#2220
OndroMih merged 5 commits into
eclipse-ee4j:mainfrom
carryel:feature/strict-CRLF-for-chunked-transfer-coding

Conversation

@carryel

@carryel carryel commented Dec 24, 2024

Copy link
Copy Markdown
Contributor

#2218 changed to be based on the main branch.
This is a PR for Issue #2217 based on main branch.

…hunked Transfer Coding" (eclipse-ee4j#2217)

+ When the org.glassfish.grizzly.http.STRICT_CHUNKED_TRANSFER_CODING_LINE_TERMINATOR_RFC_9112 option is enabled, only CRLF is allowed as the chunk-size line terminator in Chunked Transfer Coding.
+ Added testcase depending on whether option is present or not
@carryel

carryel commented Dec 24, 2024

Copy link
Copy Markdown
Contributor Author

Maven version should be upgraged in Github Actions env.

Error:  Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:3.4.1:enforce (enforce-maven) on project grizzly-project: 
Error:  Rule 1: org.apache.maven.enforcer.rules.version.RequireMavenVersion failed with message:
Error:  Detected Maven Version: 3.8.8 is not in the allowed range [3.8.9,).

@carryel
carryel requested a review from arjantijms January 23, 2025 04:36
@carryel

carryel commented Jan 23, 2025

Copy link
Copy Markdown
Contributor Author

@arjantijms @dmatej If possible, please review this as well. This is also a patch for security enhancement.

@carryel
carryel requested a review from a team February 11, 2025 04:59
private static final int[] DEC = HexUtils.getDecBytes();

public static final String STRICT_CHUNKED_TRANSFER_CODING_LINE_TERMINATOR_RFC_9112 = "org.glassfish.grizzly.http.STRICT_CHUNKED_TRANSFER_CODING_LINE_TERMINATOR_RFC_9112";
private static final boolean isStrictChunkedTransferCodingLineTerminatorSet = Boolean.parseBoolean(System.getProperty(STRICT_CHUNKED_TRANSFER_CODING_LINE_TERMINATOR_RFC_9112));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you please move this initialization from system property to the constructor and change the static field to instance field?

With that, it's more deterministic when the system property is read and the system property can be reliably set from code before creating the instance, not only using a JVM option.


private final int maxHeadersSize;

public ChunkedTransferEncoding(final int maxHeadersSize) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you can, would you create an overloaded constructor that accepts Properties and attempts to read the config from there before it reads the config from System properties?

And to complement it, would you also create overloaded constructors with a Properties argument in HttpServerFilter, HttpCodecFilter, and HttpClientFilter that pass it to ChunkedTransferEncoding?

If not, I'll try to do that in another PR, but it would really help. With this, it would be then possible to configure this option in constructor, individually for each server config, rather than using a system property for all listeners. Later we would integrate it in GlassFish to allow setting this property via standard GlassFish config for each listenerrather than via a global system property.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand. I'll look into it later.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@OndroMih I applied your suggestion.

While modifying, I thought a little about the priority of Properties and system properties and how values ​​are applied. The current implementation is to apply only one of the two, and to give priority to the Properties setting.

PS) Another way is to merge or override the settings.

carryel added 2 commits May 9, 2025 10:34
…hunked Transfer Coding" (eclipse-ee4j#2217)

+ Constructors with a Properties argument are supported.

Therefore, the functionality is available in each listener using separate Properties.
The relationship between Properties and a global system property is mutually exclusive, and Properties has priority.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants