Created
November 12, 2011 03:14
-
-
Save pminkov/1359978 to your computer and use it in GitHub Desktop.
Middleware class to simulate http errors.
This file contains 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
from django.http import HttpResponse | |
IN_ERROR_MODE = False | |
class SimulatorMiddleware: | |
"""Modifies the HTTP response. | |
""" | |
def process_request(self, request): | |
if request.path.startswith('/http_simulate'): | |
return None | |
if IN_ERROR_MODE: | |
response = HttpResponse() | |
response.status_code = 408 | |
return response | |
else: | |
return None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment