Ejemplo n.º 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
Ejemplo n.º 2
0
 def test_http_code_name_none(self):
     self.assertEquals(None, http_code_name(444))
Ejemplo n.º 3
0
 def test_http_code_name_none(self):
     self.assertEquals(None, http_code_name(444))
Ejemplo n.º 4
0
 def test_http_code_name_work(self):
     self.assertEquals('Found', http_code_name(302))
Ejemplo n.º 5
0
 def test_http_code_name_work(self):
     self.assertEquals("Found", http_code_name(302))