File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
py/test/selenium/webdriver/common Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -71,8 +71,20 @@ def _serve_page(self, page_number):
7171
7272 def _serve_file (self , file_path ):
7373 """Serve a file from the HTML root directory."""
74- with open (file_path , encoding = "latin-1" ) as f :
75- return f .read ().encode ("utf-8" )
74+ content_type , _ = mimetypes .guess_type (file_path )
75+
76+ if content_type and (
77+ content_type .startswith ("image/" )
78+ or content_type .startswith ("application/" )
79+ or content_type .startswith ("video/" )
80+ or content_type .startswith ("audio/" )
81+ ):
82+ with open (file_path , "rb" ) as f :
83+ return f .read ()
84+ else :
85+ # text files
86+ with open (file_path , encoding = "latin-1" ) as f :
87+ return f .read ().encode ("utf-8" )
7688
7789 def _send_response (self , content_type = "text/html" ):
7890 """Send a response."""
You can’t perform that action at this time.
0 commit comments