Skip to content

Fix non-OK HTTP POST responses handling #374

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

Closed
wants to merge 2 commits into from

Conversation

chemicL
Copy link
Member

@chemicL chemicL commented Jul 4, 2025

Currently, JDK HttpClient SSE implementation incorrectly handles a non-2xx HTTP response code for POST. Instead of immediately failing the caller, it ignores the issue and the user awaits until the timeout kicks in.

A related problem happened with the WebClient Streamable HTTP implementation, where the error was swallowed for non-400 responses.

Currently, JDK HttpClient SSE implementation incorrectly handles a
non-2xx HTTP response code for POST. Instead of immediately failing the
caller, it ignores the issue and the user awaits until the timeout kicks
in.

A related problem happened with the WebClient Streamable HTTP
implementation, where the error was swallowed for non-400 responses.

Signed-off-by: Dariusz Jędrzejczyk <[email protected]>
@chemicL
Copy link
Member Author

chemicL commented Jul 4, 2025

@tzolov I noticed this change fails some cases of HttpClientSseClientTransportTests, which seem to be incorrect, as the server returns a 400 HTTP code due to incorrect input.

Also, I noticed the HttpClientSseClientTransportTests.TestHttpClientSseClientTransport has a Sink which is never consumed. I don't quite get how these tests are working.

I'll leave this in a draft state for you to investigate.

@tzolov tzolov marked this pull request as ready for review July 8, 2025 16:26
@tzolov
Copy link
Contributor

tzolov commented Jul 8, 2025

@chemicL , I fixed the tests. The 400 was due to the HTTP version.
I also changed the implementation & tests to make use of the events sink, similar to the WebFluxSseClientTransportTests. Even added a test handler to track the passing messages.
But it seems that the simulateMessageEvent is useless for both the WebFluxSseClientTransportTests and the HttpClientSseClientTransportTests

- Set HttpClient to use HTTP/1.1 version explicitly
- Add Content-Type: application/json header to HttpRequest builder
- Update TestHttpClientSseClientTransport constructor in test class
@tzolov tzolov force-pushed the http-clients-fix-post-error-handling branch from bd5699f to 5313dd1 Compare July 9, 2025 12:06
tzolov pushed a commit that referenced this pull request Jul 11, 2025
Currently, JDK HttpClient SSE implementation incorrectly handles a
non-2xx HTTP response code for POST. Instead of immediately failing the
caller, it ignores the issue and the user awaits until the timeout kicks
in.

Set HttpClient to use HTTP/1.1 version explicitly for tests

A related problem happened with the WebClient Streamable HTTP
implementation, where the error was swallowed for non-400 responses.

Signed-off-by: Dariusz Jędrzejczyk <[email protected]>
@tzolov tzolov added this to the 0.11.0 milestone Jul 11, 2025
@tzolov
Copy link
Contributor

tzolov commented Jul 11, 2025

Rebased, squashed and merged at 95df67e

@tzolov tzolov closed this Jul 11, 2025
@tzolov tzolov deleted the http-clients-fix-post-error-handling branch July 11, 2025 06:37
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.

2 participants