changeset 984:311492a91530

add a Retry-After header for 503 result code (surge protection)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Tue, 18 Jul 2006 11:34:23 +0200
parents ef39854bac93
children eaae4bcf60f3
files MoinMoin/request/__init__.py
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/request/__init__.py	Mon Jul 17 13:27:35 2006 +0200
+++ b/MoinMoin/request/__init__.py	Tue Jul 18 11:34:23 2006 +0200
@@ -984,12 +984,16 @@
             403: 'FORBIDDEN',
             503: 'Service unavailable',
         }
-        self.http_headers([
+        headers = [
             'Status: %d %s' % (resultcode, statusmsg[resultcode]),
             'Content-Type: text/plain'
-        ])
+        ]
+        # when surge protection triggered, tell bots to come back later...
+        if resultcode == 503:
+            headers.append('Retry-After: %d' % self.cfg.surge_lockout_time)
+        self.http_headers(headers)
+        self.setResponseCode(resultcode)
         self.write(msg)
-        self.setResponseCode(resultcode)
         self.forbidden = True
 
     def makeForbidden403(self):