blob: 1d4c6664ae45c01cb8790868b0e287af2e44e44f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
module http_post_utilities
implicit none
character(*), parameter::content_type_required = "application/x-www-form-urlencoded"
contains
function read_post_contents() result(res)
use query_utilities, only: query
use logging
implicit none
type(query)::res
character(len=:), allocatable::transfered
character(256)::header_info
integer::content_length, istat, i
call get_environment_variable("CONTENT_LENGTH", header_info, status=istat)
if(istat == 0) then
read(header_info, *) content_length
else
content_length = 0
end if
call get_environment_variable("CONTENT_TYPE", header_info, status=istat)
if(content_length > 0 .and. &
istat == 0 .and. &
trim(header_info) == content_type_required) &
then
allocate(character(len=content_length) :: transfered)
do i = 1, content_length
read(*, '(A1)', advance='no') transfered(i:i)
end do
call res%init(transfered)
deallocate(transfered)
end if
end function read_post_contents
end module http_post_utilities
|