Esempio n. 1
0
 def challenge(self, environ, status, app_headers, forget_headers):
     """Return a 401 page unconditionally."""
     headers = app_headers + forget_headers
     # The HTTP status code and reason may not be the default ones:
     status_parts = _HTTP_STATUS_PATTERN.search(status)
     if status_parts:
         reason = status_parts.group('reason')
         code = int(status_parts.group('code'))
     else:
         reason = 'HTTP Unauthorized'
         code = 401
     # Building the response:
     response = HTTPUnauthorized(headers=headers)
     response.title = reason
     response.code = code
     return response
Esempio n. 2
0
 def challenge(self, environ, status, app_headers, forget_headers):
     """Return a 401 page unconditionally."""
     headers = app_headers + forget_headers
     remove_header(headers, 'content-length')
     # The HTTP status code and reason may not be the default ones:
     status_parts = _HTTP_STATUS_PATTERN.search(status)
     if status_parts:
         reason = status_parts.group('reason')
         code = int(status_parts.group('code'))
     else:
         reason = 'HTTP Unauthorized'
         code = 401
     # Building the response:
     response = HTTPUnauthorized(headers=headers)
     response.title = reason
     response.code = code
     return response