You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
In some cases we don't want to read the full body of a request but still send a response code and headers back to the client. Think of a resource that is used for uploading 10MB large files that wants to throttle clients by sending 429 status code and Retry-After headers to the client.
In this code path, you don't have a ErrorHandler processing that Exception into what you want the response to look like.
So the default error handling is executing, nothing you did in the Response is kept, as that Response is uncommitted at the point in time that you failed with the TooManyRequestsException.
On the server, call callback.succeeded() on the Handler's Callback parameter.
On the client, the response will arrive, but likely the request will fail to upload, causing the whole exchange to fail, so client.newRequest(..)...send() will likely throw.
You need to use the asynchronous APIs, and use send(result -> {}) where you can inspect result.getResponse() to get the 429 and the Retry-After header, and organize yourself a retry using the HttpClient.scheduler.
The Result itself will be failed due to a request failure, but the response should be ok.
If you send response content with the 429, it is best if you intercept the onResponseHeaders(response -> {}) event, and organize the retry from there, because the response content may be dropped and cause a response failure as well (although the response headers will still be available).
Jetty version(s)
12.0.15
Jetty Environment
core
Java version/vendor
(use: java -version)
21
OS type/version
Linux
Description
In some cases we don't want to read the full body of a request but still send a response code and headers back to the client. Think of a resource that is used for uploading 10MB large files that wants to throttle clients by sending 429 status code and Retry-After headers to the client.
This has been discussed on the following mailing list thread:
https://www.eclipse.org/lists/jetty-users/msg10850.html
How to reproduce?
The text was updated successfully, but these errors were encountered: