aboutsummaryrefslogtreecommitdiff
path: root/captain/response.f90
diff options
context:
space:
mode:
Diffstat (limited to 'captain/response.f90')
-rw-r--r--captain/response.f9028
1 files changed, 19 insertions, 9 deletions
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)