| OLD | NEW |
| 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 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 import re | 5 import re |
| 6 # F0401: 7,0: Unable to import 'webapp2' | 6 # F0401: 7,0: Unable to import 'webapp2' |
| 7 # pylint: disable=F0401 | 7 # pylint: disable=F0401 |
| 8 import webapp2 | 8 import webapp2 |
| 9 | 9 |
| 10 import cache | 10 import cache |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 meta_file_name = helper.get_revision_path(tag) | 71 meta_file_name = helper.get_revision_path(tag) |
| 72 elif tag_type =='ver': | 72 elif tag_type =='ver': |
| 73 meta_file_name = helper.get_version_path(tag) | 73 meta_file_name = helper.get_version_path(tag) |
| 74 else: | 74 else: |
| 75 self.abort(404) | 75 self.abort(404) |
| 76 | 76 |
| 77 meta_content = file_reader.read(helper, meta_file_name) | 77 meta_content = file_reader.read(helper, meta_file_name) |
| 78 if meta_content: | 78 if meta_content: |
| 79 zip_file_name = meta_content.strip(' \t\n') | 79 zip_file_name = meta_content.strip(' \t\n') |
| 80 else: | 80 else: |
| 81 # Check for a known issue when devs have local commits in Blink repo, | |
| 82 # which makes lastchange.py to put a Git commit hash into | |
| 83 # LASTCHANGE.blink file. | |
| 84 if tag_type == 'rev' and re.match(r'^@[0-9a-f]{40}$', tag): | |
| 85 self.error(404) | |
| 86 self.response.write( | |
| 87 '<h1>404 Not Found</h1>' | |
| 88 'Are you building Chromium yourself? ' | |
| 89 'If yes, please make sure you have synced past commit ' | |
| 90 '<b>#335156</b>, run the following command, and then rebuild:' | |
| 91 '<div style="font-family:monospace;margin:1em;">' | |
| 92 'python build/util/lastchange.py -s third_party/WebKit ' | |
| 93 '--git-svn-go-deeper > build/util/LASTCHANGE.blink</div>') | |
| 94 return | |
| 95 self.abort(404) | 81 self.abort(404) |
| 96 | 82 |
| 97 content = zip_proxy.read(helper, zip_file_name, path) | 83 content = zip_proxy.read(helper, zip_file_name, path) |
| 98 if not content: | 84 if not content: |
| 99 self.abort(404) | 85 self.abort(404) |
| 100 content = content_processor.process(path, content) | 86 content = content_processor.process(path, content) |
| 101 cache.set_content(cache_key_name, content) | 87 cache.set_content(cache_key_name, content) |
| 102 | 88 |
| 103 self.response.headers['Content-Type'] = content_type.from_path(path) | 89 self.response.headers['Content-Type'] = content_type.from_path(path) |
| 104 self.response.headers['Access-Control-Allow-Origin'] = '*' | 90 self.response.headers['Access-Control-Allow-Origin'] = '*' |
| 105 cache_control = 'public, max-age=%d' % helper.get_max_age() | 91 cache_control = 'public, max-age=%d' % helper.get_max_age() |
| 106 self.response.headers['Cache-Control'] = cache_control | 92 self.response.headers['Cache-Control'] = cache_control |
| 107 self.response.body = content | 93 self.response.body = content |
| 108 | 94 |
| 109 class LegacyStatic(Server): | 95 class LegacyStatic(Server): |
| 110 def get(self, version, path): | 96 def get(self, version, path): |
| 111 # Map x.x.x.x -> x.x.x.0 to deal with patched releases | 97 # Map x.x.x.x -> x.x.x.0 to deal with patched releases |
| 112 match = re.search('(\d+\.\d+\.\d+\.)\d+', version) | 98 match = re.search('(\d+\.\d+\.\d+\.)\d+', version) |
| 113 if match: | 99 if match: |
| 114 return super(LegacyStatic, self).get('ver', match.group(1) + '0', path) | 100 return super(LegacyStatic, self).get('ver', match.group(1) + '0', path) |
| 115 else: | 101 else: |
| 116 self.abort(404) | 102 self.abort(404) |
| 117 | 103 |
| 118 app = webapp2.WSGIApplication( | 104 app = webapp2.WSGIApplication( |
| 119 [('/', MainPage), | 105 [('/', MainPage), |
| 120 ('/precache_url', pre_cacher.PreCacherFromUrl), | 106 ('/precache_url', pre_cacher.PreCacherFromUrl), |
| 121 webapp2.Route('/serve_<tag_type>/<tag>/<path:.*>', Server), | 107 webapp2.Route('/serve_<tag_type>/<tag>/<path:.*>', Server), |
| 122 webapp2.Route('/static/<version>/<path:.*>', LegacyStatic)], | 108 webapp2.Route('/static/<version>/<path:.*>', LegacyStatic)], |
| 123 debug=config.IS_DEV_APP_SERVER) | 109 debug=config.IS_DEV_APP_SERVER) |
| OLD | NEW |