set_auth Function

private function set_auth(curl_ptr, request) result(status)

Set the user name and password for Authentication.


It sends the user name and password over the network in plain text, easily captured by others.

Arguments

Type IntentOptional Attributes Name
type(c_ptr), intent(out) :: curl_ptr

Pointer to the CURL handle.

type(request_type), intent(inout) :: request

The HTTP request

Return Value integer

An integer indicating whether the operation was successful (0) or not (non-zero).


Contents

Source Code


Source Code

    function set_auth(curl_ptr, request) result(status)
        !!> Set the user name and password for Authentication. 
        !!_____
        !!> It sends the user name and password over the network in plain text, easily captured by others.
        type(c_ptr), intent(out) :: curl_ptr
            !! Pointer to the CURL handle.
        type(request_type), intent(inout) :: request
            !! The HTTP request
        integer :: status
            !! An integer indicating whether the operation was successful (0) or not (non-zero).

        if(allocated(request%auth)) then
            status = curl_easy_setopt(curl_ptr, CURLOPT_HTTPAUTH, CURLAUTH_BASIC)
            status = curl_easy_setopt(curl_ptr, CURLOPT_USERNAME, request%auth%name)
            status = curl_easy_setopt(curl_ptr, CURLOPT_PASSWORD, request%auth%value)
        else 
            ! No curl function was called so set status to zero.
            status = 0
        end if
    end function set_auth