aboutsummaryrefslogtreecommitdiff
path: root/captain/external.f90
diff options
context:
space:
mode:
authorJeffrey Armstrong <jeff@approximatrix.com>2021-05-04 16:44:20 -0400
committerJeffrey Armstrong <jeff@approximatrix.com>2021-05-04 16:44:20 -0400
commit877b8876b078c8ab2632c17ab09e0ac0c2789c8a (patch)
treeba63e85cdaaef78aedc006854125312ff6607b21 /captain/external.f90
parente789ce4a4bc1f0894a707d2a141bbf357e0ba2d5 (diff)
downloadlevitating-877b8876b078c8ab2632c17ab09e0ac0c2789c8a.tar.gz
levitating-877b8876b078c8ab2632c17ab09e0ac0c2789c8a.zip
Initial work on the CGI interface for web access.
Diffstat (limited to 'captain/external.f90')
-rw-r--r--captain/external.f9082
1 files changed, 2 insertions, 80 deletions
diff --git a/captain/external.f90 b/captain/external.f90
index 00f34ff..7b1826a 100644
--- a/captain/external.f90
+++ b/captain/external.f90
@@ -668,39 +668,6 @@ contains
end function external_input_request_gemini
- function is_request_static(req)
- use server_response
- use logging
- implicit none
-
- class(request), intent(in)::req
- logical::is_request_static
- character(64)::first, last
-
- character(4)::ext
- integer::j
-
- call req%path_component(1, first)
- call req%last_component(last)
-
- j = index(last, ".", back=.true.)
- if(j > 0) then
- ext = last(j+1:len_trim(last))
- else
- ext = " "
- end if
-
- call write_log("Static check: "//trim(first), LOG_DEBUG)
-
- is_request_static = ((trim(first) == "releases") .or. &
- (trim(first) == "uploads") .or. &
- (trim(first) == "results") .or. &
- (trim(first) == "static") .or. &
- (trim(first) == "favicon.txt") .or. &
- (trim(first) == "instructions" .and. trim(ext) == "json"))
-
- end function is_request_static
-
function is_redirect_action(req)
use server_response
implicit none
@@ -733,52 +700,6 @@ contains
end function external_redirect_action_request_gemini
- function external_request_static(req) result(resp)
- use logging
- use config
- use utilities
- use server_response
- use special_filenames
- implicit none
-
- class(request), intent(in)::req
- type(response)::resp
- character(64)::category
- character(256)::filename
- logical::exists
-
- resp%temporary_file = .false.
-
- call req%path_component(1, category)
- call req%path_component(2, filename)
-
- resp%body_filename => get_special_full_filename(trim(category), trim(filename))
-
- inquire(file=resp%body_filename, exist=exists)
- if(.not. exists) then
- resp%code = GEMINI_CODE_PERMFAIL
- call write_log("File did not exist: "//resp%body_filename, LOG_NORMAL)
- else
- resp%code = GEMINI_CODE_SUCCESS
-
- if(index(filename, ".gmi") /= 0) then
- resp%body_mimetype = "text/gemini"
-
- else if(index(filename, ".txt") /= 0) then
- resp%body_mimetype = "text/plain"
-
- else if(index(filename, ".json") /= 0) then
- resp%body_mimetype = "text/plain"
-
- ! Just a catch-all, whatever...
- else
- resp%body_mimetype = "application/octet-stream"
-
- end if
- end if
-
- end function external_request_static
-
function external_request_templated(req) result(resp)
use page_template
use config, only: template_filepath, project
@@ -872,6 +793,7 @@ contains
function external_request_gemini(req) result(resp)
use server_response
use logging
+ use request_utils, only: is_request_static, request_static
implicit none
class(request), intent(in)::req
@@ -891,7 +813,7 @@ contains
else if(is_request_static(req)) then
call write_log("Req static", LOG_INFO)
- resp = external_request_static(req)
+ resp = request_static(req)
else
call write_log("Req template", LOG_INFO)