| OLD | NEW |
| 1 # Copyright (c) 2011 Google Inc. All rights reserved. | 1 # Copyright (c) 2011 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 with codecs.open(file_path, "rb") as static_file: | 127 with codecs.open(file_path, "rb") as static_file: |
| 128 self.send_response(200) | 128 self.send_response(200) |
| 129 self._send_access_control_header() | 129 self._send_access_control_header() |
| 130 self.send_header("Content-Length", os.path.getsize(file_path)) | 130 self.send_header("Content-Length", os.path.getsize(file_path)) |
| 131 mime_type, encoding = mimetypes.guess_type(file_path) | 131 mime_type, encoding = mimetypes.guess_type(file_path) |
| 132 if mime_type: | 132 if mime_type: |
| 133 self.send_header("Content-type", mime_type) | 133 self.send_header("Content-type", mime_type) |
| 134 | 134 |
| 135 if cacheable_seconds: | 135 if cacheable_seconds: |
| 136 expires_time = (datetime.datetime.now() + | 136 expires_time = (datetime.datetime.now() + |
| 137 datetime.timedelta(0, cacheable_seconds)) | 137 datetime.timedelta(0, cacheable_seconds)) |
| 138 expires_formatted = wsgiref.handlers.format_date_time( | 138 expires_formatted = wsgiref.handlers.format_date_time( |
| 139 time.mktime(expires_time.timetuple())) | 139 time.mktime(expires_time.timetuple())) |
| 140 self.send_header("Expires", expires_formatted) | 140 self.send_header("Expires", expires_formatted) |
| 141 self.end_headers() | 141 self.end_headers() |
| 142 | 142 |
| 143 if not headers_only: | 143 if not headers_only: |
| 144 shutil.copyfileobj(static_file, self.wfile) | 144 shutil.copyfileobj(static_file, self.wfile) |
| 145 | 145 |
| 146 def _serve_xml(self, xml): | 146 def _serve_xml(self, xml): |
| 147 self.send_response(200) | 147 self.send_response(200) |
| 148 self._send_access_control_header() | 148 self._send_access_control_header() |
| 149 self.send_header("Content-type", "text/xml") | 149 self.send_header("Content-type", "text/xml") |
| 150 self.end_headers() | 150 self.end_headers() |
| 151 xml = xml.encode('utf-8') | 151 xml = xml.encode('utf-8') |
| 152 self.wfile.write(xml) | 152 self.wfile.write(xml) |
| OLD | NEW |