Skip to content

Commit 7f3121c

Browse files
Copilotdarrelmiller
andcommitted
Allow both Token and String formats for quota policy identifiers
Co-authored-by: darrelmiller <[email protected]>
1 parent 99bd68f commit 7f3121c

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

draft-ietf-httpapi-ratelimit-headers.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,20 +138,22 @@ The term "problem type" in this document is to be interpreted as described in [P
138138

139139
# RateLimit-Policy Field {#ratelimit-policy-field}
140140

141-
The "RateLimit-Policy" response header field is a non-empty List{{SF}} of Quota Policy Items ({{quotapolicy-item}}). The Item{{SF}} value MUST be a Token{{SF}}.
141+
The "RateLimit-Policy" response header field is a non-empty List{{SF}} of Quota Policy Items ({{quotapolicy-item}}). The Item{{SF}} value MUST be either a Token{{SF}} or a String{{SF}}.
142142

143143
The field value SHOULD remain consistent over a sequence of HTTP responses. It is this characteristic that differentiates it from the [RateLimit](#ratelimit-field) field that contains information that MAY change on every request. The "RateLimit-Policy" field enables clients to control their own flow of requests based on policy information provided by the server. Situations where throttling constraints are highly dynamic are better served using the [RateLimit field](#ratelimit-field) that communicates the latest service information a client can react to. Both fields can be communicated by the server when appropriate.
144144

145145
Lists of Quota Policy Items ({{quotapolicy-item}}) can be split over multiple "RateLimit-Policy" fields in the same HTTP response as described in {{Section 3.1 of SF}}.
146146

147147
~~~
148-
RateLimit-Policy: burst;q=100;w=60,daily;q=1000;w=86400
148+
RateLimit-Policy: burst;q=100;w=60,"daily";q=1000;w=86400
149149
~~~
150150

151151
## Quota Policy Item {#quotapolicy-item}
152152

153153
A quota policy Item contains an identifier for the policy and a set of Parameters{{SF}} that contain information about a server's capacity allocation for the policy.
154154

155+
The policy identifier can be expressed as either a Token{{SF}} (unquoted) or a String{{SF}} (quoted). Tokens are more compact but are limited by Token syntax rules (e.g., cannot start with a digit, cannot contain spaces). Strings provide more flexibility by allowing any character sequence but require quotes.
156+
155157
The following parameters are defined:
156158

157159
q:
@@ -205,10 +207,10 @@ This field MAY convey the time window associated with the quota, as shown in thi
205207
RateLimit-Policy: default;q=100;w=10
206208
~~~
207209

208-
These examples show multiple policies being returned:
210+
Policy identifiers can be expressed as Tokens (unquoted) or Strings (quoted). Both formats are acceptable and can be mixed:
209211

210212
~~~
211-
RateLimit-Policy: permin;q=50;w=60,perhr;q=1000;w=3600
213+
RateLimit-Policy: permin;q=50;w=60,"per hour";q=1000;w=3600
212214
~~~
213215

214216
The following example shows a policy with a partition key:
@@ -227,7 +229,7 @@ The following example shows a policy with a partition key and a quota unit:
227229

228230
A server uses the "RateLimit" response header field to communicate the current service limit for a quota policy for a particular partition key.
229231

230-
The field is expressed as a List{{SF}} of Service Limit Items ({{servicelimit-item}}). The Item{{SF}} value MUST be a Token{{SF}}.
232+
The field is expressed as a List{{SF}} of Service Limit Items ({{servicelimit-item}}). The Item{{SF}} value MUST be either a Token{{SF}} or a String{{SF}}.
231233

232234
Lists of Service Limit Items can be split over multiple "RateLimit" fields in the same HTTP response as described in {{Section 3.1 of SF}}.
233235

@@ -239,6 +241,8 @@ Lists of Service Limit Items can be split over multiple "RateLimit" fields in th
239241

240242
Each service limit Item{{SF}} identifies the quota policy ({{quotapolicy-item}}) associated with the request and contains Parameters{{SF}} with information about the current service limit.
241243

244+
The policy identifier can be expressed as either a Token{{SF}} (unquoted) or a String{{SF}} (quoted), matching the format used in the corresponding RateLimit-Policy field.
245+
242246
The following parameters are defined in this specification:
243247

244248
r:
@@ -294,10 +298,10 @@ This example shows a remaining quota of 999 requests for a partition key that ha
294298
RateLimit: default;r=999;pk=:dHJpYWwxMjEzMjM=:
295299
~~~
296300

297-
This example shows a 300MB remaining quota for an application in the next 60 seconds:
301+
This example shows a 300MB remaining quota for an application in the next 60 seconds, using a quoted String identifier:
298302

299303
~~~
300-
RateLimit: default;r=300000000;t=60;pk=:QXBwLTk5OQ==:
304+
RateLimit: "default";r=300000000;t=60;pk=:QXBwLTk5OQ==:
301305
~~~
302306

303307
# Problem Types {#problem-types}
@@ -1068,8 +1072,8 @@ Response:
10681072
~~~ http-message
10691073
HTTP/1.1 200 OK
10701074
Content-Type: application/json
1071-
RateLimit-Policy: hour;q=1000;w=3600, day;q=5000;w=86400
1072-
RateLimit: day;r=100;t=36000
1075+
RateLimit-Policy: hour;q=1000;w=3600, "day";q=5000;w=86400
1076+
RateLimit: "day";r=100;t=36000
10731077

10741078
{"hello": "world"}
10751079
~~~
@@ -1153,7 +1157,7 @@ RateLimit:default;r=50;t=60
11531157

11541158
~~~
11551159
RateLimit-Policy: sliding;q=100;w=60;burst=1000
1156-
RateLimit-Policy: fixed;q=5000;w=3600;burst=0
1160+
RateLimit-Policy: "fixed";q=5000;w=3600;burst=0
11571161
RateLimit: sliding;r=50;t=44
11581162
~~~
11591163

0 commit comments

Comments
 (0)