| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 from fnmatch import fnmatch | 5 from fnmatch import fnmatch |
| 6 import logging | 6 import logging |
| 7 import mimetypes | 7 import mimetypes |
| 8 import posixpath | 8 import posixpath |
| 9 import traceback | 9 import traceback |
| 10 from urlparse import urlsplit | 10 from urlparse import urlsplit |
| 11 | 11 |
| 12 from data_source_registry import CreateDataSources | 12 from data_source_registry import CreateDataSources |
| 13 from file_system import FileNotFoundError | 13 from file_system import FileNotFoundError |
| 14 from redirector import Redirector | 14 from redirector import Redirector |
| 15 from servlet import Servlet, Response | 15 from servlet import Servlet, Response |
| 16 from svn_constants import DOCS_PATH, PUBLIC_TEMPLATE_PATH | |
| 17 from third_party.handlebar import Handlebar | 16 from third_party.handlebar import Handlebar |
| 18 | 17 |
| 19 | 18 |
| 20 def _MakeHeaders(content_type): | 19 def _MakeHeaders(content_type): |
| 21 return { | 20 return { |
| 22 'X-Frame-Options': 'sameorigin', | 21 'X-Frame-Options': 'sameorigin', |
| 23 'Content-Type': content_type, | 22 'Content-Type': content_type, |
| 24 'Cache-Control': 'max-age=300', | 23 'Cache-Control': 'max-age=300', |
| 25 } | 24 } |
| 26 | 25 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 content = content_and_type.content | 97 content = content_and_type.content |
| 99 if isinstance(content, Handlebar): | 98 if isinstance(content, Handlebar): |
| 100 content = server_instance.template_renderer.Render(content, self._request) | 99 content = server_instance.template_renderer.Render(content, self._request) |
| 101 | 100 |
| 102 content_type = content_and_type.content_type | 101 content_type = content_and_type.content_type |
| 103 if isinstance(content, unicode): | 102 if isinstance(content, unicode): |
| 104 content = content.encode('utf-8') | 103 content = content.encode('utf-8') |
| 105 content_type += '; charset=utf-8' | 104 content_type += '; charset=utf-8' |
| 106 | 105 |
| 107 return Response.Ok(content, headers=_MakeHeaders(content_type)) | 106 return Response.Ok(content, headers=_MakeHeaders(content_type)) |
| OLD | NEW |