Bug 60997 - Enhance SemaphoreValve to support denied status and path matching
Summary: Enhance SemaphoreValve to support denied status and path matching
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 9
Classification: Unclassified
Component: Catalina (show other bugs)
Version: unspecified
Hardware: All All
: P2 enhancement (vote)
Target Milestone: -----
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-04-17 07:16 UTC by romain.manni-bucau
Modified: 2024-03-11 14:31 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description romain.manni-bucau 2017-04-17 07:16:28 UTC
Hi,

would be great to enrich the SemaphoreValve to support few more things. Obvious and easy ones are:

1. deniedStatus and have a default implementation of permitDenied setting this status (Note: if not possible in current valve a EnhancedSemaphoreValve would be good enough)
2. controlConcurrency should enable to match a requestUri, I guess a includeRequestUris and excludeRequestUris is the way to go

On probably a bit more difficult side, it would be great to support asynchronism limiting. This one can require to move the valve to a filter to be able to wrap the AsyncContext to have the right hooks but this would make it fully functional.

Finally: this valve provides concurrent limit but is there any plan to have rate limiting (based on a time slot)?
Comment 1 Remy Maucherat 2024-03-11 10:59:40 UTC
I started looking at 2) since I think I saw the request somewhere else as well in the past, but it was a bit messy (I tried using RequestFilterValve as well).

Instead I added a new feature to the rewrite valve: https://github.com/apache/tomcat/commit/7a3bbc6e300ced35268fe1c46c90f6b5c752dc5c
Since it allows skipping the next valve, if the semaphore valve is configured right after the rewrite valve, it can simply how over it if when a rule matches.
Comment 2 Remy Maucherat 2024-03-11 14:31:01 UTC
Implemented in 11-M19, 10.1.20 and 9.0.88.