Skip to content

Commit

Permalink
fix idaholab#431, unencrypted, unzipped extracted file download not w…
Browse files Browse the repository at this point in the history
…orking
  • Loading branch information
mmguero committed Feb 26, 2024
1 parent cebdae7 commit ec3c7f2
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions file-monitor/scripts/extracted_files_http_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,15 +344,14 @@ def do_GET(self):
):
# serve the asset file
satisfied = True
ctype = self.guess_type(fullpath)
with open(fullpath, 'rb') as fhandle:
fs = os.fstat(fhandle.fileno())
with open(fullpath, 'rb') as f:
fs = os.fstat(f.fileno())
self.send_response(200)
self.send_header('Content-type', self.guess_type(fullpath))
self.send_header("Content-Length", str(fs[6]))
self.send_header("Last-Modified", self.date_time_string(fs.st_mtime))
self.end_headers()
while chunk := fhandle.read(1024):
while chunk := f.read(1024):
self.wfile.write(chunk)

# handle regular file downloads
Expand Down Expand Up @@ -402,7 +401,15 @@ def do_GET(self):

else:
# original file, unencrypted
SimpleHTTPRequestHandler.do_GET(self)
with open(fullpath, 'rb') as f:
fs = os.fstat(f.fileno())
self.send_response(200)
self.send_header('Content-type', self.guess_type(fullpath))
self.send_header("Content-Length", str(fs[6]))
self.send_header("Last-Modified", self.date_time_string(fs.st_mtime))
self.end_headers()
while chunk := f.read(1024):
self.wfile.write(chunk)

else:
self.send_error(404, "Not Found")
Expand Down

0 comments on commit ec3c7f2

Please sign in to comment.