Skip to content

Commit 80af507

Browse files
authored
Fix bugs discovered by Intel OneAPI (#43)
* Fix bugs discovered by Intel OneAPI * Fix comment * Add note about the supported compilers
1 parent 6b900ae commit 80af507

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,13 @@ fpm test
9999
```
100100
Running the tests will validate the behavior of the package and help identify any issues or regressions.
101101

102+
### Supported compilers
103+
104+
http-client is known to work with the following compilers:
105+
106+
* GFortran 11 & 12 (tested in CI)
107+
* Intel OneAPI ifx v2023.1.0 and ifort classic v2021.9.0
108+
102109
### **Contributing guidelines**
103110

104111
When contributing to the http Fortran package, please keep the following guidelines in mind:
@@ -112,4 +119,4 @@ When contributing to the http Fortran package, please keep the following guideli
112119

113120
We appreciate your contributions and look forward to your valuable input in improving the http Fortran package.
114121

115-
Happy coding!
122+
Happy coding!

src/http/http_client.f90

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,11 +319,11 @@ function set_body(curl_ptr, request) result(status)
319319
type(c_ptr) :: mime_ptr, part_ptr
320320

321321
! if only data is passed
322-
if(len(request%data) > 0) then
322+
if (allocated(request%data)) then
323323
status = set_postfields(curl_ptr, request%data)
324324

325325
! if file is passsed
326-
else if(len(request%file%name) > 0) then
326+
else if (allocated(request%file)) then
327327
mime_ptr = curl_mime_init(curl_ptr)
328328
part_ptr = curl_mime_addpart(mime_ptr)
329329
status = curl_mime_filedata(part_ptr, request%file%value)
@@ -345,14 +345,17 @@ function set_body(curl_ptr, request) result(status)
345345
end if
346346

347347
! if only form is passed
348-
else if(allocated(request%form)) then
348+
else if (allocated(request%form)) then
349349
request%form_encoded_str = prepare_form_encoded_str(curl_ptr, request)
350350
status = set_postfields(curl_ptr, request%form_encoded_str)
351351

352352
! setting the Content-Type header to application/x-www-form-urlencoded, used for sending form data
353353
if (.not. pair_has_name(request%header, 'Content-Type')) then
354354
call append_pair(request%header, 'Content-Type', 'application/x-www-form-urlencoded')
355355
end if
356+
else
357+
! No curl function was called so set status to zero.
358+
status = 0
356359
end if
357360

358361
end function set_body

src/http/http_request.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ module http_request
3636
!! An Array of request headers.
3737
type(pair_type), allocatable :: form(:)
3838
!! An array of fields in an HTTP form.
39-
type(pair_type) :: file
39+
type(pair_type), allocatable :: file
4040
!! Used to store information about files to be sent in HTTP requests.
4141
end type request_type
4242
end module http_request

0 commit comments

Comments
 (0)