From b27bd7cfa58eb82fc2a6c76aaa848e07a6fa7c24 Mon Sep 17 00:00:00 2001 From: Jeffrey Armstrong Date: Fri, 2 Apr 2021 13:08:37 -0400 Subject: API calls to the gemini interface should work. API calls to the titan interface need implementation. --- captain/response.f90 | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'captain/response.f90') diff --git a/captain/response.f90 b/captain/response.f90 index e1d80eb..2f48caa 100644 --- a/captain/response.f90 +++ b/captain/response.f90 @@ -24,6 +24,8 @@ module server_response procedure :: destroy => response_destroy procedure :: set_message => response_set_message procedure :: set_url => response_set_url + procedure :: set_body_contents => response_temp_file_contents + procedure :: set_filename => response_set_filename_using_allocation end type @@ -255,4 +257,47 @@ contains end subroutine response_set_url + subroutine response_temp_file_contents(resp, str, mimetype) + use utilities, only: generate_temporary_filename + implicit none + + class(response)::resp + character(*), intent(in)::str + character(*), intent(in), optional::mimetype + + integer::unum + + resp%body_filename => generate_temporary_filename() + open(newunit=unum, file=resp%body_filename, action="write", status="new") + write(unum, *) str + close(unum) + + resp%temporary_file = .true. + + if(present(mimetype)) then + resp%body_mimetype = mimetype + else + resp%body_mimetype = "text/plain" + end if + + end subroutine response_temp_file_contents + + subroutine response_set_filename_using_allocation(resp, fname, mimetype) + implicit none + + class(response)::resp + character(*), intent(in)::fname + character(*), intent(in), optional::mimetype + + allocate(character(len=len_trim(fname)) :: resp%body_filename) + resp%body_filename = trim(fname) + + if(present(mimetype)) then + resp%body_mimetype = mimetype + else + resp%body_mimetype = "text/plain" + end if + + end subroutine response_set_filename_using_allocation + end module server_response -- cgit v1.2.3