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

Issue #7102 - WebClient should have a mode that is resilient to bad media/content types #9040

Merged
merged 2 commits into from
Jul 30, 2024

Conversation

Tomas-Kraus
Copy link
Member

fixes issue #7102
backport of issue #6774 fix

@Tomas-Kraus Tomas-Kraus self-assigned this Jul 26, 2024
@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Jul 26, 2024
…t to bad media/content types

Signed-off-by: Tomáš Kraus <[email protected]>
Copy link
Member

@Verdent Verdent left a comment

Choose a reason for hiding this comment

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

I have a 2 questions. :-)

  1. Why have you decided to drop ParserMode enum, which was used in the 4.x implementation?
  2. I think I have not seen it also in the 4.x version, but should not these relaxed formats of the content types be also configurable? I mean if user wants to add their own.

client.get()
.path("/invalidContentType")
.request()
.await();
Copy link
Member

Choose a reason for hiding this comment

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

Please set timeout to the await method.

client.get()
.path("/invalidTextContentType")
.request()
.await();
Copy link
Member

Choose a reason for hiding this comment

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

add timeout please.

WebClientResponse response = client.get()
.path("/invalidTextContentType")
.request()
.await();
Copy link
Member

Choose a reason for hiding this comment

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

add timeout please.

assertThat(maybeContentType.get().toString(), is(RELAXED_CONTENT_TYPE_TEXT));
}

private static final String INVALID_CONTENT_TYPE_VALUE = "invalid header value";
Copy link
Member

Choose a reason for hiding this comment

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

constants should be at the top of the class.

private static final String INVALID_CONTENT_TYPE_VALUE = "invalid header value";

// HTTP service with invalid Content-Type
private static void invalidContentType(ServerRequest request, ServerResponse response) {
Copy link
Member

Choose a reason for hiding this comment

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

Move also these static methods under the beforeAll method please. I could not find them when trying to figure out what the endpoint does.

@Test
void testInvalidTextContentTypeStrict() {
try {
client.get()
Copy link
Member

Choose a reason for hiding this comment

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

I think this formatting should be padded.

@Tomas-Kraus
Copy link
Member Author

1. Why have you decided to drop ParserMode enum, which was used in the 4.x implementation?

MediaType in 4.x is rewritten. It's parse method is not public so changing prototype did not cause any issues.
MediaType parse method in 3.x is public static and as I understand it properly, it shall match current prototype to be used as method reference. That's the reason why I made it without ParserMode enum and mode is choosen by the method being called.

2. I think I have not seen it also in the 4.x version, but should not these relaxed formats of the content types be also configurable? I mean if user wants to add their own.

4.x version has hard-coded relaxed format as well. I made it the way jeff requested. This issue is just backport, not any additional enhancement to be done in 3.x only.

@Tomas-Kraus Tomas-Kraus requested a review from Verdent July 26, 2024 15:42
@Tomas-Kraus Tomas-Kraus changed the title Issue #7102 - WebClient should have a mode that is resilient to bad m… Issue #7102 - WebClient should have a mode that is resilient to bad media/content types Jul 30, 2024
@Tomas-Kraus Tomas-Kraus merged commit 52152f4 into helidon-io:helidon-3.x Jul 30, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[3.x] WebClient should have a mode that is resilient to bad media/content types
3 participants