aboutsummaryrefslogtreecommitdiff
path: root/captain/requtils.f90
diff options
context:
space:
mode:
authorJeffrey Armstrong <jeff@approximatrix.com>2025-01-03 17:19:57 -0500
committerJeffrey Armstrong <jeff@approximatrix.com>2025-01-03 17:19:57 -0500
commitf7fc2a99bc435bfa699c710f2f6204d99379e1c2 (patch)
treee718e1d58621f18ab14a0c9d66d8e014cb65faa6 /captain/requtils.f90
parentf43007b637900d17c6c0ecdb9aeeab4393e03c3f (diff)
downloadlevitating-f7fc2a99bc435bfa699c710f2f6204d99379e1c2.tar.gz
levitating-f7fc2a99bc435bfa699c710f2f6204d99379e1c2.zip
Results should now be gzipd as they arrive and unzipped only upon request.
Diffstat (limited to 'captain/requtils.f90')
-rw-r--r--captain/requtils.f9029
1 files changed, 29 insertions, 0 deletions
diff --git a/captain/requtils.f90 b/captain/requtils.f90
index 03fe869..a993eeb 100644
--- a/captain/requtils.f90
+++ b/captain/requtils.f90
@@ -241,6 +241,29 @@ contains
end function is_request_static
+ subroutine try_static_gzipd_file(resp, exist)
+ use server_response
+ implicit none
+
+ type(response), intent(inout)::resp
+ logical, intent(out)::exist
+
+ character(len=:), pointer::gzfilename
+
+ allocate(character(len=(len_trim(resp%body_filename) + 3)) :: gzfilename)
+
+ gzfilename = trim(resp%body_filename)//".gz"
+ inquire(file=gzfilename, exist=exist)
+ if(exist) then
+ ! Unzip but keep the compressed version
+ call execute_command_line('gunzip -k "'//gzfilename//'"', wait=.true.)
+
+ ! Mark the file as temporary because we can delete it after transfer
+ resp%temporary_file = .true.
+ end if
+
+ end subroutine try_static_gzipd_file
+
function request_static(req) result(resp)
use logging
use config
@@ -272,8 +295,14 @@ contains
resp%body_filename => get_special_full_filename(trim(category), trim(filename))
inquire(file=resp%body_filename, exist=exists)
+
+ ! See if a gzip version is around
if(.not. exists) then
+ call try_static_gzipd_file(resp, exist=exists)
+ end if
+ if(.not. exists) then
+
resp%code = notfound_code(req)
call write_log("File did not exist: "//resp%body_filename, LOG_NORMAL)