C++
C++
Transition from Http.GetHead to Http.HttpNoBody
Provides instructions for replacing deprecated GetHead method calls with HttpNoBody.Chilkat C++ Downloads
#include <CkHttp.h>
#include <CkHttpResponse.h>
void ChilkatSample(void)
{
bool success = false;
CkHttp http;
const char *url = "https://www.example.com/";
// ------------------------------------------------------------------------
// The GetHead method is deprecated:
CkHttpResponse *resp1 = http.GetHead(url);
if (http.get_LastMethodSuccess() == false) {
std::cout << http.lastErrorText() << "\r\n";
return;
}
std::cout << resp1->get_StatusCode() << "\r\n";
delete resp1;
// ------------------------------------------------------------------------
// Do the equivalent using HttpNoBody.
// Your application creates a new, empty response object which is passed
// in the last argument and filled with the HTTP response upon success.
CkHttpResponse resp2;
success = http.HttpNoBody("HEAD",url,resp2);
if (success == false) {
std::cout << http.lastErrorText() << "\r\n";
return;
}
std::cout << resp2.get_StatusCode() << "\r\n";
}