isapir commented on code in PR #767:
URL: https://github.com/apache/tomcat/pull/767#discussion_r1828114910
##########
java/org/apache/catalina/util/RateLimiter.java:
##########
@@ -65,4 +94,33 @@ public interface RateLimiter {
* @param filterConfig The FilterConfig used to configure the associated
filter
*/
void setFilterConfig(FilterConfig filterConfig);
-}
+
+ /**
+ * Minimum set of rate limit header fields.
+ *
+ * @see <a HREF=
+ *
"https://www.ietf.org/archive/id/draft-ietf-httpapi-ratelimit-headers-08.html#name-service-limit-item">ietf
+ * Ratelimit Headers Draft</a>
+ */
+ public static class RateLimitItem {
+ private String policyName;
+ private int remainingQuota;
+
+ /**
+ * @param name of policy associated
+ * @param remaining quota units for the identified policy
+ * @param timeLeftUntilReset number of seconds until the quota
associated with the quota policy resets
+ */
+ public RateLimitItem(String policyName, int remainingQuota) {
+ this.policyName = policyName;
+ this.remainingQuota = remainingQuota;
+ }
+
+ @Override
+ public String toString() {
+ StringBuffer buf = new StringBuffer();
+
buf.append('"').append(this.policyName).append('"').append(";r=").append(this.remainingQuota);
Review Comment:
`String.format()` will make the code much more readable here
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]