Fix WsgiLimiterProxy check

The code in the WsgiLimiterProxy checks the response
from the proxy to be in the range [200, 299] to
determine if an API request must be rate limited, but
the check currently corresponds to checking for <=200.

This may not have been consequential since a Proxy
is not expected to set the "X-Wait-Seconds" header in
the response when there is nothing to delay - so, even
with this incorrect check, we weren't rate limiting
incorrectly with a proxy that was setup correctly.

Change-Id: Id58a87b24b19e1d489fe808d11d59cc93df390f2
Closes-Bug: #1823750
Signed-off-by: Goutham Pacha Ravi <gouthampravi@gmail.com>
This commit is contained in:
Goutham Pacha Ravi 2020-08-27 10:31:22 -07:00
parent 90bf1cee86
commit 090d903b70
1 changed files with 2 additions and 1 deletions

View File

@ -421,7 +421,8 @@ class WsgiLimiterProxy(object):
resp = conn.getresponse()
if 200 >= resp.status < 300:
if resp.status >= 200 and resp.status < 300:
# there's nothing to rate-limit
return None, None
return resp.getheader("X-Wait-Seconds"), resp.read() or None