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