diff options
Diffstat (limited to 'protocol.f90')
-rw-r--r-- | protocol.f90 | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/protocol.f90 b/protocol.f90 index 52b6430..130c866 100644 --- a/protocol.f90 +++ b/protocol.f90 @@ -48,7 +48,6 @@ contains if(send_string(conn%ssl, url//c_carriage_return//c_new_line, trimming=.false.)) then bytes_received = retrieve_characters(conn%ssl, buffer) - Print *, bytes_received do while(bytes_received > 0) do i=1, bytes_received @@ -115,4 +114,35 @@ contains end subroutine get_redirect_url + subroutine handle_relative_url(current_url, path) + implicit none + + character(*), intent(inout)::current_url + character(*), intent(in)::path + + integer::past_protocol, first_slash, last_slash + + past_protocol = index(current_url, "://") + if(past_protocol > 0) then + + past_protocol = past_protocol + 3 + + if(path(1:1) == "/") then + + first_slash = index(current_url(past_protocol:len_trim(current_url)), "/") + current_url = current_url(1:(past_protocol + first_slash - 1))//path + + else + + last_slash = index(current_url, "/", back=.true.) + if(last_slash > 0) then + current_url = current_url(1:last_slash)//path + end if + + end if + + end if + + end subroutine handle_relative_url + end module gemini_protocol
\ No newline at end of file |