aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--captain/response.f9024
-rw-r--r--common/protocol.f9032
2 files changed, 47 insertions, 9 deletions
diff --git a/captain/response.f90 b/captain/response.f90
index 1c7a0b5..9cd2d9f 100644
--- a/captain/response.f90
+++ b/captain/response.f90
@@ -140,8 +140,6 @@ contains
do while(i /= i_last .and. j < i_component)
j = j + 1
- call write_log("RC: "//self%location(i:n))
-
i_last = i
i = index(self%location(i_last+1:n), "/")
i = i_last + i
@@ -151,7 +149,6 @@ contains
if(j == i_component) then
if(i == i_last) then
res = self%location(i_last+1:n)
- call write_log("Last! "//trim(res))
else
res = self%location(i_last+1:i-1)
end if
@@ -389,8 +386,8 @@ contains
self%location = regular_request%location(1:i-1)
size_text => titan_get_request_value(regular_request%location, "size")
- read(size_text, *, iostat=ierr) self%size
- if(ierr <= 0) then
+ read(size_text, '(I16)', iostat=ierr) self%size
+ if(ierr /= 0) then
self%size = 0
end if
deallocate(size_text)
@@ -420,6 +417,7 @@ contains
subroutine titan_write_to_filename(self, filename)
use jessl, only: ssl_read
+ use logging
implicit none
class(titan_request)::self
@@ -432,16 +430,26 @@ contains
integer(kind=8)::bytes_to_go
integer::i
- open(newunit=unum, file=filename, status="unknown", action="write", access="stream")
+ character(128)::msg
+
+ open(newunit=unum, file=filename, status="unknown", action="write", access="stream", form="formatted")
bytes_to_go = self%size
-
+ call write_log("Writing!")
+
do while(bytes_to_go > 0)
bufread = ssl_read(self%ssl_connection, buf)
bytes_to_go = bytes_to_go - bufread
+ write(msg, *) "read: ", bufread
+ call write_log(trim(msg))
+
+ write(msg, *) "remaining: ", bytes_to_go
+ call write_log(trim(msg))
+
+
do i = 1, bufread
- write(unum, '(A1)', advance='no') buf(i:i)
+ write(unum, '(A1)', advance='no') buf(i)
end do
end do
diff --git a/common/protocol.f90 b/common/protocol.f90
index 38f2cf1..37e3205 100644
--- a/common/protocol.f90
+++ b/common/protocol.f90
@@ -230,6 +230,11 @@ contains
logical, dimension(4)::successes
integer::i, ierr, bytes_read, bytes_written, total_written
+ ! For direct processing of the reponse line
+ integer::response_line_index, bytes_received
+ character(1024)::response_line
+ logical::response_line_completed
+
returncode = -1
rewind(unit_number)
@@ -278,7 +283,32 @@ contains
end do
if(total_written >= file_length) then
- returncode = STATUS_SUCCESS
+
+ response_line_completed = .false.
+ response_line = " "
+ response_line_index = 0
+
+ bytes_received = retrieve_characters(conn%ssl, buffer)
+ do while(bytes_received > 0)
+
+ do i=1, bytes_received
+ response_line_index = response_line_index + 1
+ response_line(response_line_index:response_line_index) = buffer(i)
+
+ ! If we encountered our first newline, we have a complete status
+ ! line - handle it here
+ if(buffer(i) == char(10) .or. response_line_index == 1024) then
+ response_line_completed = .true.
+
+ returncode = get_return_code(response_line)
+
+ end if
+
+ end do
+
+ bytes_received = retrieve_characters(conn%ssl, buffer)
+ end do
+
else
returncode = STATUS_LOCALFAIL
end if