-
Notifications
You must be signed in to change notification settings - Fork 433
MSC4041: http header Retry-After for http code 429 #4041
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
39435c4
http header Retry-After for http code 429
ThomasHalwax 3c49478
MSC id
ThomasHalwax cce98eb
Update proposals/4041-retry-after-header-rate-limiting.md
ThomasHalwax 4aadd41
notes on backward compatibility
ThomasHalwax 1e7b099
fixes https://github.com/matrix-org/matrix-spec-proposals/pull/4041#d…
ThomasHalwax 8424e8f
fixed typos
ThomasHalwax 8a9b9cb
made calculation of the Retry-After header value less explicit
ThomasHalwax c0bb1d8
Update proposals/4041-retry-after-header-rate-limiting.md
ThomasHalwax 296d54c
Merge branch 'main' of github.com:syncpoint/matrix-spec-proposals
ThomasHalwax b6fc456
retry_after_ms gets deprecated
ThomasHalwax 0796450
explicit advice for server and client
ThomasHalwax ca3b072
* moved deprecation into proposal
ThomasHalwax File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| # MSC4041: Use http header Retry-After to enable library-assisted retry handling | ||
|
|
||
| The current Matrix Client-Server API (v1.7) recommends that home servers should protect themselves from | ||
| being overloaded by enforcing rate-limits to selected API calls. | ||
| If home servers limit access to an API they respond with an http error code 429 and a response body | ||
| that includes a property `retry_after_ms` to indicate how long a client has to wait before retrying. | ||
|
|
||
| Some http libraries (like [Ky](https://github.com/sindresorhus/ky), [got](https://github.com/sindresorhus/got | ||
| and [urllib3](https://urllib3.readthedocs.io/en/stable/reference/urllib3.util.html#urllib3.util.Retry)) ease | ||
| the burden of handling retries by honoring the http header `Retry-After`. As explained in | ||
| [RFC 9119 - HTTP Semantics](https://www.rfc-editor.org/rfc/rfc9110#field.retry-after) this header is optional | ||
| and contains either a (relative) value for the delay in seconds or an (absolute) date. | ||
|
|
||
| The current Matrix Client Server API specification does not take this header into account. This wastes the | ||
| potential that current http libraries offer in terms of automated retry handling. | ||
|
|
||
| ## Proposal | ||
|
|
||
| In order to allow developers to make use of the automated retry handling capabilities of http libraries | ||
| home servers should add an http header `Retry-After` in case they respond with an http error 429. | ||
| Since the body of the response already contains a property `retry_after_ms` (in __milliseconds__) the value | ||
| of `Retry-After` (in __seconds__) should be the calculated in order to comply with the specification in | ||
| [RFC 9119 - HTTP Semantics](https://www.rfc-editor.org/rfc/rfc9110#field.retry-after). | ||
|
|
||
| ## Potential issues | ||
|
|
||
| With the introduction of the http header `Retry-After` the usage of the `retry_after_ms` property in the response body becomes deprecated. | ||
ThomasHalwax marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Existing SDKs may use client libraries that might be able to honor the http header `Retry-After`. Since | ||
| this header is currently not part of the response developers might have created purpose-built functions | ||
| in order to handle rate-limiting correctly. | ||
turt2live marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| In order to maintain backward compatibility with existing client libraries home servers must use both the `Retry-After` header and the | ||
| `retry_after_ms` property in the response body. | ||
|
|
||
| Client libraries shall use the values in this order: | ||
|
|
||
| 1) `Retry-After` http header. | ||
| 2) `retry_after_ms` property in the response body. | ||
ThomasHalwax marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Alternatives | ||
|
|
||
| N/A | ||
|
|
||
| ## Security considerations | ||
|
|
||
| N/A | ||
|
|
||
| ## Unstable prefix | ||
|
|
||
| Since this MSC is using a standard HTTP header, it will not use a unstable prefix. | ||
|
|
||
| ## Dependencies | ||
|
|
||
| N/A | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.