diff options
Diffstat (limited to 'captain/response.f90')
-rw-r--r-- | captain/response.f90 | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/captain/response.f90 b/captain/response.f90 index 610b070..dfce5e7 100644 --- a/captain/response.f90 +++ b/captain/response.f90 @@ -63,6 +63,7 @@ implicit none character(len=:), pointer::location => null() character(len=:), pointer::page => null() character(len=:), pointer::query_string => null() + character(len=4)::method = "GET" contains @@ -73,6 +74,8 @@ implicit none procedure :: path_component_int => request_component_int procedure :: path_starting_with_component => request_component_starting_with procedure :: component => request_component_func + procedure :: is_get => request_is_get + procedure :: is_post => request_is_post end type request @@ -94,13 +97,14 @@ implicit none contains - subroutine request_init(self, str, server_explicit, protocol_explicit) + subroutine request_init(self, str, server_explicit, protocol_explicit, method) use logging + use utilities, only: toupper implicit none class(request) :: self character(*), intent(in)::str - character(*), intent(in), optional::server_explicit, protocol_explicit + character(*), intent(in), optional::server_explicit, protocol_explicit, method character(len=:), allocatable::temppage integer::i, j, n @@ -179,6 +183,11 @@ contains self%page = temppage end if deallocate(temppage) + + if(present(method)) then + self%method = method + call toupper(self%method) + end if end subroutine request_init @@ -328,6 +337,26 @@ contains end subroutine request_last_component + function request_is_get(self) result(res) + implicit none + + class(request)::self + logical::res + + res = (self%method == "GET") + + end function request_is_get + + function request_is_post(self) result(res) + implicit none + + class(request)::self + logical::res + + res = (self%method == "POST") + + end function request_is_post + subroutine request_destroy(self) implicit none |