This function sets the HTTP
method
for the request.
method
argument can take one of the following values:
HTTP_GET
,HTTP_HEAD
,HTTP_POST
,HTTP_PUT
,HTTP_DELETE
,HTTP_PATCH
. If any other value is provided, an error will be thrown.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(c_ptr), | intent(out) | :: | curl_ptr |
Pointer to the |
||
integer, | intent(in) | :: | method |
Specifies the HTTP |
||
type(response_type), | intent(out) | :: | response |
The HTTP |
The status
of setting HTTP method.
function set_method(curl_ptr, method, response) result(status)
!!> This function sets the **HTTP `method`** for the request.
!!____
!!#### **The `method` argument can take one of the following values:**
!!> `HTTP_GET`, `HTTP_HEAD`, `HTTP_POST`, `HTTP_PUT`, `HTTP_DELETE`,
!!> `HTTP_PATCH`. If any other value is provided, an **error will be thrown**.
type(c_ptr), intent(out) :: curl_ptr
!! Pointer to the `curl` handler.
integer, intent(in) :: method
!! Specifies the HTTP `method` to use.
type(response_type), intent(out) :: response
!! The HTTP `response` from the server.
integer :: status
!! The `status` of setting HTTP method.
select case(method)
case(1)
status = curl_easy_setopt(curl_ptr, CURLOPT_CUSTOMREQUEST, 'GET' )
response%method = 'GET'
case(2)
status = curl_easy_setopt(curl_ptr, CURLOPT_CUSTOMREQUEST, 'HEAD' )
response%method = 'HEAD'
case(3)
status = curl_easy_setopt(curl_ptr, CURLOPT_CUSTOMREQUEST, 'POST' )
response%method = 'POST'
case(4)
status = curl_easy_setopt(curl_ptr, CURLOPT_CUSTOMREQUEST, 'PUT' )
response%method = 'PUT'
case(5)
status = curl_easy_setopt(curl_ptr, CURLOPT_CUSTOMREQUEST, 'DELETE' )
response%method = 'DELETE'
case(6)
status = curl_easy_setopt(curl_ptr, CURLOPT_CUSTOMREQUEST, 'PATCH' )
response%method = 'PATCH'
case default
error stop 'Method argument can be either HTTP_GET, HTTP_HEAD, HTTP_POST, HTTP_PUT, HTTP_DELETE, HTTP_PATCH'
end select
end function set_method