gpAux/extensions/gps3ext/src/s3restful_service.cpp
// head() will execute HTTP HEAD RESTful API with given url/headers/params, and return the HTTP
// response code.
//
// Currently, this method only return the HTTP code, will be extended if needed in the future
// implementation.
head() will execute HTTP HEAD RESTful API with given url/headers/params, and return the HTTP
response code.

Currently, this method only return the HTTP code, will be extended if needed in the future
implementation.
head () will execute HTTP HEAD RESTful API with given url / headers / params and return the HTTP response code . Currently this method only return the HTTP code will be extended if needed in the future implementation .
ResponseCode S3RESTfulService::head(const string &url, HTTPHeaders &headers,
                                    const map<string, string> &params) {
    ResponseCode responseCode = HeadResponseFail;
    CURL *curl = curl_easy_init();
    CHECK_OR_DIE_MSG(curl != NULL, "%s", "Failed to create curl handler");
    headers.CreateList();
    curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
    curl_easy_setopt(curl, CURLOPT_FORBID_REUSE, 1L);
    curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1L);
    curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers.GetList());
    curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "HEAD");
    curl_easy_setopt(curl, CURLOPT_NOBODY, 1L);
    map<string, string>::const_iterator iter = params.find("debug");
    if (iter != params.end() && iter->second == "true") {
        curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
    }
    if (s3ext_debug_curl) {
        curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
    }
    CURLcode res = curl_easy_perform(curl);
    if (res != CURLE_OK) {
        S3ERROR("curl_easy_perform() failed: %s", curl_easy_strerror(res));
    } else {
        curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &responseCode);
    }
    curl_easy_cleanup(curl);
    headers.FreeList();
    return responseCode;
}
ResponseCode S3RESTfulService :: head ( const string & url , HTTPHeaders & headers , const map < string , string > & params ) { ResponseCode responseCode = HeadResponseFail ; CURL * curl = curl_easy_init ( ) ; CHECK_OR_DIE_MSG ( curl != NULL , " " , " " ) ; headers . CreateList ( ) ; curl_easy_setopt ( curl , CURLOPT_URL , url . c_str ( ) ) ; curl_easy_setopt ( curl , CURLOPT_FORBID_REUSE , 1L ) ; curl_easy_setopt ( curl , CURLOPT_NOSIGNAL , 1L ) ; curl_easy_setopt ( curl , CURLOPT_HTTPHEADER , headers . GetList ( ) ) ; curl_easy_setopt ( curl , CURLOPT_CUSTOMREQUEST , " " ) ; curl_easy_setopt ( curl , CURLOPT_NOBODY , 1L ) ; map < string , string > :: const_iterator iter = params . find ( " " ) ; if ( iter != params . end ( ) && iter -> second == " " ) { curl_easy_setopt ( curl , CURLOPT_VERBOSE , 1L ) ; } if ( s3ext_debug_curl ) { curl_easy_setopt ( curl , CURLOPT_VERBOSE , 1L ) ; } CURLcode res = curl_easy_perform ( curl ) ; if ( res != CURLE_OK ) { S3ERROR ( " " , curl_easy_strerror ( res ) ) ; } else { curl_easy_getinfo ( curl , CURLINFO_RESPONSE_CODE , & responseCode ) ; } curl_easy_cleanup ( curl ) ; headers . FreeList ( ) ; return responseCode ; }
head() will execute HTTP HEAD RESTful API with given url/headers/params, and return the HTTP
response code.
head () will execute HTTP HEAD RESTful API with given url / headers / params and return the HTTP response code .
// Get the HTTP response status code from HTTP header