We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix cannot support play mp4 static file in safari browser.
remi/server.py -> App -> _process_all
before
filename = self._get_static_file(static_file.groups()[0]) if not filename: self.send_response(404) return mimetype, encoding = mimetypes.guess_type(filename) self.send_response(200) self.send_header('Content-type', mimetype if mimetype else 'application/octet-stream') if self.server.enable_file_cache: self.send_header('Cache-Control', 'public, max-age=86400') self.end_headers() with open(filename, 'rb') as f: content = f.read() self.wfile.write(content)
after
filename = self._get_static_file(static_file.groups()[0]) if not filename: self.send_response(404) return mimetype, encoding = mimetypes.guess_type(filename) response_code = 200 content = None send_response_code = None with open(filename, 'rb') as f: content = f.read() for k in self.headers: if k.lower() == 'range': self._log.info('Start resumable pass.') # self._log.info(self.headers) range_value = self.headers[k] range_value_comp = re.compile(r'bytes=([0-9]+)\-(([0-9]+)?)') m = re.match(range_value_comp, range_value) if m: start_range = m.group(1) start = int(start_range) end_range = m.group(2) if len(end_range) > 0: end = int(end_range) else: end = -1 print(start, end_range, len(content)) if end == len(content) -1: response_code = 200 else: response_code = 206 self.send_response(response_code) send_response_code = True if end == -1: # headers['Content-Length'] = str(len(content) - start) self.send_header('Content-Length', str(len(content) - start)) else: # headers['Content-Length'] = str(end - start + 1 self.send_header('Content-Length', str(end - start + 1)) if end < 0: content_range_header_value = "bytes %d-%d/%d" % (start, len(content) - 1, len(content)) content = content[start:len(content)] else: content_range_header_value = "bytes %d-%d/%d" % (start, end, len(content)) content = content[start:end + 1] # headers['Content-Range'] = content_range_header_value self.send_header('Content-Range', content_range_header_value) if not send_response_code: self.send_response(response_code) self.send_header('Content-type', mimetype if mimetype else 'application/octet-stream') if self.server.enable_file_cache: self.send_header('Cache-Control', 'public, max-age=86400') self.end_headers() if content: self.wfile.write(content)
The text was updated successfully, but these errors were encountered:
Thank you, I will study and embed this ;-)
Sorry, something went wrong.
No branches or pull requests
fix cannot support play mp4 static file in safari browser.
before
after
The text was updated successfully, but these errors were encountered: