equal
deleted
inserted
replaced
245 try: |
245 try: |
246 body.decode('utf-8') |
246 body.decode('utf-8') |
247 except UnicodeError, e: |
247 except UnicodeError, e: |
248 logging.warning('Response written is not UTF-8: %s', e) |
248 logging.warning('Response written is not UTF-8: %s', e) |
249 |
249 |
|
250 if (self.headers.get('Cache-Control') == 'no-cache' and |
|
251 not self.headers.get('Expires')): |
|
252 self.headers['Expires'] = 'Fri, 01 Jan 1990 00:00:00 GMT' |
250 self.headers['Content-Length'] = str(len(body)) |
253 self.headers['Content-Length'] = str(len(body)) |
251 write = start_response('%d %s' % self.__status, self.__wsgi_headers) |
254 write = start_response('%d %s' % self.__status, self.__wsgi_headers) |
252 write(body) |
255 write(body) |
253 self.out.close() |
256 self.out.close() |
254 |
257 |
461 See the example in the module comments for details. |
464 See the example in the module comments for details. |
462 |
465 |
463 The URL mapping is first-match based on the list ordering. |
466 The URL mapping is first-match based on the list ordering. |
464 """ |
467 """ |
465 |
468 |
|
469 REQUEST_CLASS = Request |
|
470 RESPONSE_CLASS = Response |
|
471 |
466 def __init__(self, url_mapping, debug=False): |
472 def __init__(self, url_mapping, debug=False): |
467 """Initializes this application with the given URL mapping. |
473 """Initializes this application with the given URL mapping. |
468 |
474 |
469 Args: |
475 Args: |
470 url_mapping: list of (URI, RequestHandler) pairs (e.g., [('/', ReqHan)]) |
476 url_mapping: list of (URI, RequestHandler) pairs (e.g., [('/', ReqHan)]) |
475 WSGIApplication.active_instance = self |
481 WSGIApplication.active_instance = self |
476 self.current_request_args = () |
482 self.current_request_args = () |
477 |
483 |
478 def __call__(self, environ, start_response): |
484 def __call__(self, environ, start_response): |
479 """Called by WSGI when a request comes in.""" |
485 """Called by WSGI when a request comes in.""" |
480 request = Request(environ) |
486 request = self.REQUEST_CLASS(environ) |
481 response = Response() |
487 response = self.RESPONSE_CLASS() |
482 |
488 |
483 WSGIApplication.active_instance = self |
489 WSGIApplication.active_instance = self |
484 |
490 |
485 handler = None |
491 handler = None |
486 groups = () |
492 groups = () |