Skip to content

Commit 71d0375

Browse files
added error handeling, for wrong http method
1 parent 5f29322 commit 71d0375

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/http.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module http
22
use http_request, only : HTTP_DELETE, HTTP_GET, HTTP_HEAD, HTTP_PATCH, HTTP_POST, HTTP_POST
33
use http_response, only : response_type
4-
use http_server, only : request
4+
use http_client, only : request
55
end module http

src/http/http_server.f90 renamed to src/http/http_client.f90

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
module http_server
1+
module http_client
22
use iso_c_binding
33
use curl
44
use http_request, only : request_type
55
use http_response, only : response_type
66

77
implicit none
88

9-
! http_server Type
9+
! http_client Type
1010
type :: client_type
1111
type(request_type) :: request
1212
type(c_ptr) :: curl_ptr
@@ -112,6 +112,9 @@ function client_set_method(this, response) result(status)
112112
case(6)
113113
status = curl_easy_setopt(this%curl_ptr, CURLOPT_CUSTOMREQUEST, 'PATCH' // c_null_char)
114114
response%method = 'PATCH'
115+
case default
116+
! print *, "ERROR : method argument can be either HTTP_GET, HTTP_HEAD, HTTP_POST, HTTP_PUT, HTTP_DELETE, HTTP_PATCH"
117+
error stop "Method argument can be either HTTP_GET, HTTP_HEAD, HTTP_POST, HTTP_PUT, HTTP_DELETE, HTTP_PATCH"
115118
end select
116119
end function client_set_method
117120

@@ -145,4 +148,4 @@ function client_response_callback(ptr, size, nmemb, client_data) bind(c)
145148
end function client_response_callback
146149

147150

148-
end module http_server
151+
end module http_client

0 commit comments

Comments
 (0)