(C) Example: Http.QuickGetStr method
Demonstrates the QuickGetStr method.
#include <C_CkHttp.h>
void ChilkatSample(void)
{
HCkHttp http;
const char *str;
http = CkHttp_Create();
// Keep the response body if there's an error.
CkHttp_putKeepResponseBody(http,TRUE);
// Send the HTTP GET and return the content in a string.
str = CkHttp_quickGetStr(http,"https://www.chilkatsoft.com/helloWorld.json");
if (CkHttp_getLastMethodSuccess(http) == FALSE) {
if (CkHttp_getLastStatus(http) == 0) {
// Communications error. We did not get a response.
printf("%s\n",CkHttp_lastErrorText(http));
}
else {
printf("Response status code: %d\n",CkHttp_getLastStatus(http));
printf("Response body error text:\n");
printf("%s\n",CkHttp_lastResponseBody(http));
}
CkHttp_Dispose(http);
return;
}
printf("%s\n",str);
printf("Success\n");
CkHttp_Dispose(http);
}
|