Mercurial > p > roundup > code
diff roundup/rest.py @ 7156:6f09103a6522
[issue2551263] expose headers to rest clients
Expose headers for with rate limiting (X-RateLimiting*, Retry-After),
marking obsolete api endpoints (Sunset), and listing methods available
on an endpoint (Allow).
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Thu, 23 Feb 2023 15:34:44 -0500 |
| parents | 89a59e46b3af |
| children | 68ff3d2a9f6b |
line wrap: on
line diff
--- a/roundup/rest.py Thu Feb 23 12:01:33 2023 -0500 +++ b/roundup/rest.py Thu Feb 23 15:34:44 2023 -0500 @@ -2194,6 +2194,24 @@ # response may change based on Origin value. self.client.setVary("Origin") + # expose these headers to rest clients. Otherwise they can't + # respond to: + # rate limiting (*RateLimit*, Retry-After) + # obsolete API endpoint (Sunset) + # options request to discover supported methods (Allow) + self.client.setHeader( + "Access-Control-Expose-Headers", + ", ".join( [ + "X-RateLimit-Limit", + "X-RateLimit-Remaining", + "X-RateLimit-Reset", + "X-RateLimit-Limit-Period", + "Retry-After", + "Sunset", + "Allow", + ] ) + ) + # Allow-Origin must match origin supplied by client. '*' doesn't # work for authenticated requests. self.client.setHeader(
