aboutsummaryrefslogtreecommitdiff
path: root/captain/response.f90
diff options
context:
space:
mode:
authorJeffrey Armstrong <jeff@approximatrix.com>2021-04-02 13:08:37 -0400
committerJeffrey Armstrong <jeff@approximatrix.com>2021-04-02 13:08:37 -0400
commitb27bd7cfa58eb82fc2a6c76aaa848e07a6fa7c24 (patch)
treef611937418d1ea5416431715ab1f6a44d42d1905 /captain/response.f90
parentda47fdfddc46e35a939b7771eda21debec50c094 (diff)
downloadlevitating-b27bd7cfa58eb82fc2a6c76aaa848e07a6fa7c24.tar.gz
levitating-b27bd7cfa58eb82fc2a6c76aaa848e07a6fa7c24.zip
API calls to the gemini interface should work. API calls to the titan interface need implementation.
Diffstat (limited to 'captain/response.f90')
-rw-r--r--captain/response.f9045
1 files changed, 45 insertions, 0 deletions
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