-
Notifications
You must be signed in to change notification settings - Fork 2k
Open
Labels
Description
Jetty version(s)
12.1.X
Enhancement Description
Two changes to make the class QoSHandler more flexible:
- Allow configuration of the status code - Add a field and setter to configure the status code returned when limits are exceeded. It could also be the constructor parameter.
// Default to 503 for backward compatibility
private int _throttledStatus = HttpStatus.SERVICE_UNAVAILABLE_503;
public void setThrottledStatus(int status) {
_throttledStatus = status;
}
- Relax the visibility of internal rejection methods
Change the visibility of some methods fromprivatetoprotected. This would allow developers to extend the class and implement custom rejection logic (e.g., by adding specific headers such asRetry-Afteror custom JSON error bodies).
Specifically, these methods:
private boolean tooManyRequests(Response response, Callback callback)private boolean notAvailable(Response response, Callback callback)
Currently, the only way to achieve this without copying the entire class is a complex workaround involving:
- A "Marker" handler inside the QoS handler to flag successful passage.
- A "Wrapper" handler outside the QoS handler that intercepts 503 responses, checks for the absence of the marker, and swaps the code to 429
This adds unnecessary object allocation and runtime overhead for a simple status code change.