aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeffrey Armstrong <jeff@approximatrix.com>2021-04-01 12:39:06 -0400
committerJeffrey Armstrong <jeff@approximatrix.com>2021-04-01 12:39:06 -0400
commitb125906018d0d3d09baeebb096db56ca052902eb (patch)
tree5e5506a625361d7ddfcbe816a447f645567153a5
parentaf084b8acb5ed7e883e422c4626a596eb32fba25 (diff)
downloadlevitating-b125906018d0d3d09baeebb096db56ca052902eb.tar.gz
levitating-b125906018d0d3d09baeebb096db56ca052902eb.zip
Fixed request parsing to initialize a necessary variable. Minor cosmetic changes to instruction handling.
-rw-r--r--captain/external.f9012
-rw-r--r--captain/response.f9028
2 files changed, 27 insertions, 13 deletions
diff --git a/captain/external.f90 b/captain/external.f90
index ee4d2e6..d572a7e 100644
--- a/captain/external.f90
+++ b/captain/external.f90
@@ -242,10 +242,14 @@ contains
allocate(character(len=nsize) :: res)
res = nl//"## "//trim(instruction_name)
+
+ i = index(req%location, ".gmi", back=.true.)
+ res = trim(res)//nl//"=> "//req%location(1:i-1)//".json View Raw"
+
if(n_players == 0) then
res = trim(res)//nl//nl//"No players currently can run these instructions"
else
- res = trim(res)//nl//nl//"## Launch Now"
+ res = trim(res)//nl//nl//"### Launch Now"
do i = 1, n_players
call get_player_name(players(i), player_name)
if(is_player_busy(players(i))) then
@@ -255,7 +259,7 @@ contains
end if
res = trim(res)//nl//"=> "//trim(req%location)//"?launch="//trim(player_name)// &
- " "//trim(player_status)//trim(player_name)
+ " "//trim(player_status)//" "//trim(player_name)
end do
end if
@@ -361,7 +365,7 @@ contains
res = "## Instructions"
do i = 1, n
- one_player = "=> /instructions/"//trim(instruction_names(i))//".json "//trim(instruction_names(i))
+ one_player = "=> /instructions/"//trim(instruction_names(i))//".gmi "//trim(instruction_names(i))
if(i == 1) then
res = trim(res)//new_line(res(1:1))//new_line(res(1:1))//trim(one_player)
else
@@ -598,7 +602,7 @@ contains
call write_log("Processing request")
call req%path_component(1, first)
-
+
if(trim(req%location) == "/" .or. trim(req%location) == "/index.gmi") then
call write_log("Assign")
diff --git a/captain/response.f90 b/captain/response.f90
index 5463978..37eaf58 100644
--- a/captain/response.f90
+++ b/captain/response.f90
@@ -47,7 +47,7 @@ module server_response
contains
subroutine request_init(self, str)
- !use logging
+ use logging
implicit none
class(request) :: self
@@ -58,33 +58,42 @@ contains
n = len_trim(str)
allocate(character(len=n) :: self%url)
self%url = trim(str)
- !call write_log("URL: "//self%url)
+ call write_log("URL: "//self%url)
i = index(str, "://")
allocate(character(len=(i-1)) :: self%protocol)
self%protocol = str(1:i-1)
- !call write_log("Protocol: "//self%protocol)
+ call write_log("Protocol: "//self%protocol)
i = i + 3
j = index(str(i:n), "/")
+ if(j <= 0) then
+ j = len_trim(str) + 1 - i
+ end if
allocate(character(len=(j-1)) :: self%server)
self%server = str(i:(i+j-1))
- !call write_log("Server: "//self%server)
+ call write_log("Server: "//self%server//"|")
i = j+i-1
j = index(str, "?")
if(j == 0) then
- allocate(character(len=(n - i + 1)) :: self%location)
- self%location = str(i:n)
- !call write_log("Location: "//self%location)
+ if(n-i+1 == 0) then
+ allocate(character(len=1) :: self%location)
+ self%location = "/"
+ else
+ allocate(character(len=(n - i + 1)) :: self%location)
+ self%location = str(i:n)
+ end if
+ call write_log("Location: "//self%location)
+
else
allocate(character(len=(n-j)) :: self%query_string)
self%query_string = str(j+1:n)
- !call write_log("Query: "//self%query_string)
+ call write_log("Query: "//self%query_string)
allocate(character(len=(j-i)) :: self%location)
self%location = str(i:j-1)
- !call write_log("Location: "//self%location)
+ call write_log("Location: "//self%location)
end if
end subroutine request_init
@@ -103,6 +112,7 @@ contains
n = len_trim(self%location)
+ i_last = 0
j = 0
i = index(self%location, "/")
do while(i /= i_last .and. j < i_component)