forked from indymedia/epicyon
Fix http codes with tests
parent
aec28278cf
commit
281bafcf81
43
daemon.py
43
daemon.py
|
@ -617,30 +617,59 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
def _200(self) -> None:
|
def _200(self) -> None:
|
||||||
|
if self.server.translate:
|
||||||
self._httpReturnCode(200, self.server.translate['Ok'],
|
self._httpReturnCode(200, self.server.translate['Ok'],
|
||||||
self.server.translate['This is nothing less ' +
|
self.server.translate['This is nothing ' +
|
||||||
'than an utter triumph'])
|
'less than an utter ' +
|
||||||
|
'triumph'])
|
||||||
|
else:
|
||||||
|
self._httpReturnCode(200, 'Ok',
|
||||||
|
'This is nothing less ' +
|
||||||
|
'than an utter triumph')
|
||||||
|
|
||||||
def _404(self) -> None:
|
def _404(self) -> None:
|
||||||
|
if self.server.translate:
|
||||||
self._httpReturnCode(404, self.server.translate['Not Found'],
|
self._httpReturnCode(404, self.server.translate['Not Found'],
|
||||||
self.server.translate['These are not the ' +
|
self.server.translate['These are not the ' +
|
||||||
'droids you are ' +
|
'droids you are ' +
|
||||||
'looking for'])
|
'looking for'])
|
||||||
|
else:
|
||||||
|
self._httpReturnCode(404, 'Not Found',
|
||||||
|
'These are not the ' +
|
||||||
|
'droids you are ' +
|
||||||
|
'looking for')
|
||||||
|
|
||||||
def _304(self) -> None:
|
def _304(self) -> None:
|
||||||
|
if self.server.translate:
|
||||||
self._httpReturnCode(304, self.server.translate['Not changed'],
|
self._httpReturnCode(304, self.server.translate['Not changed'],
|
||||||
self.server.translate['The contents of your ' +
|
self.server.translate['The contents of ' +
|
||||||
'local cache are up ' +
|
'your local cache ' +
|
||||||
'to date'])
|
'are up to date'])
|
||||||
|
else:
|
||||||
|
self._httpReturnCode(304, 'Not changed',
|
||||||
|
'The contents of ' +
|
||||||
|
'your local cache ' +
|
||||||
|
'are up to date')
|
||||||
|
|
||||||
def _400(self) -> None:
|
def _400(self) -> None:
|
||||||
|
if self.server.translate:
|
||||||
self._httpReturnCode(400, self.server.translate['Bad Request'],
|
self._httpReturnCode(400, self.server.translate['Bad Request'],
|
||||||
self.server.translate['Better luck next time'])
|
self.server.translate['Better luck ' +
|
||||||
|
'next time'])
|
||||||
|
else:
|
||||||
|
self._httpReturnCode(400, 'Bad Request',
|
||||||
|
'Better luck next time')
|
||||||
|
|
||||||
def _503(self) -> None:
|
def _503(self) -> None:
|
||||||
|
if self.server.translate:
|
||||||
self._httpReturnCode(503, self.server.translate['Unavailable'],
|
self._httpReturnCode(503, self.server.translate['Unavailable'],
|
||||||
self.server.translate['The server is busy. ' +
|
self.server.translate['The server is busy. ' +
|
||||||
'Please try again later'])
|
'Please try again ' +
|
||||||
|
'later'])
|
||||||
|
else:
|
||||||
|
self._httpReturnCode(503, 'Unavailable',
|
||||||
|
'The server is busy. Please try again ' +
|
||||||
|
'later')
|
||||||
|
|
||||||
def _write(self, msg) -> None:
|
def _write(self, msg) -> None:
|
||||||
tries = 0
|
tries = 0
|
||||||
|
|
Loading…
Reference in New Issue