aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocol.f909
-rw-r--r--request.f9019
2 files changed, 26 insertions, 2 deletions
diff --git a/protocol.f90 b/protocol.f90
index e8039d3..502778c 100644
--- a/protocol.f90
+++ b/protocol.f90
@@ -33,6 +33,8 @@ implicit none
integer, parameter::STATUS_LOCALFAIL = -1
integer, parameter::BUFFER_SIZE = 256
+
+ integer, parameter::gemini_default_port = 1965
contains
@@ -83,6 +85,7 @@ contains
integer, intent(in)::unit_number
character(*), intent(out)::return_type
character(*), intent(in), optional::server_name
+ integer::port
integer::returncode
@@ -99,8 +102,12 @@ contains
if(present(server_name)) then
allocate(character(len=len_trim(server_name)) :: server)
server = server_name
+ port = gemini_default_port
else
- call get_server_from_url(url, server)
+ call get_server_from_url(url, server, port)
+ if(port < 0) then
+ port = gemini_default_port
+ end if
end if
! Correct URL relative paths
diff --git a/request.f90 b/request.f90
index 7308a9e..ec35772 100644
--- a/request.f90
+++ b/request.f90
@@ -164,13 +164,17 @@ contains
end subroutine close_connection
- subroutine get_server_from_url(url, server)
+ subroutine get_server_from_url(url, server, port)
implicit none
character(*), intent(in)::url
character(:), allocatable, intent(out)::server
+ integer, intent(out)::port
integer::start_server, end_server, length
+ integer::start_port, iostatus
+
+ port = -1
start_server = index(url, "://")
if(start_server > 0) then
@@ -189,6 +193,19 @@ contains
server = url(start_server:end_server)
end if
+
+ ! Need to check if a port was specified too
+ start_port = index(server, ":")
+ if(start_port > 0) then
+
+ read(server(start_port+1:len_trim(server)), *, iostat=iostatus) port
+ if(iostatus /= 0) then
+ port = -1
+ end if
+
+ server = server(1:start_port-1)
+
+ end if
end subroutine get_server_from_url