C++
C++
Example: Http.QuickGetStr method
Demonstrates theQuickGetStr method.
Chilkat C++ Downloads
#include <CkHttp.h>
void ChilkatSample(void)
{
CkHttp http;
// Keep the response body if there's an error.
http.put_KeepResponseBody(true);
// Send the HTTP GET and return the content in a string.
const char *str = http.quickGetStr("https://www.chilkatsoft.com/helloWorld.json");
if (http.get_LastMethodSuccess() == false) {
if (http.get_LastStatus() == 0) {
// Communications error. We did not get a response.
std::cout << http.lastErrorText() << "\r\n";
}
else {
std::cout << "Response status code: " << http.get_LastStatus() << "\r\n";
std::cout << "Response body error text:" << "\r\n";
std::cout << http.lastResponseBody() << "\r\n";
}
return;
}
std::cout << str << "\r\n";
std::cout << "Success" << "\r\n";
}