Пример #1
0
 def _handle_http_exception(error):
     """Handler for flask.exceptions.HTTPException"""
     error_headers = error.get_response(flask.request.environ).headers
     add_headers = [header for header in error_headers
                    if header[0].lower() not in ('content-type',
                                                 'content-length')]
     response = { 'message': http_code_message(error.code) }
     name = http_code_name(error.code)
     if name:
         response['error-type'] = name
     if error.code == 401:
         add_headers.append(('WWW-Authenticate', 'Basic realm="Altai"'))
     return response, error.code, add_headers
Пример #2
0
 def test_http_code_name_none(self):
     self.assertEquals(None, http_code_name(444))
Пример #3
0
 def test_http_code_name_none(self):
     self.assertEquals(None, http_code_name(444))
Пример #4
0
 def test_http_code_name_work(self):
     self.assertEquals('Found', http_code_name(302))
Пример #5
0
 def test_http_code_name_work(self):
     self.assertEquals("Found", http_code_name(302))