aboutsummaryrefslogtreecommitdiff
path: root/captain/requtils.f90
diff options
context:
space:
mode:
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)