Unicode C
Unicode C
Example: Http.QuickGetSb method
Demonstrates theQuickGetSb method.
Chilkat Unicode C Downloads
#include <C_CkHttpW.h>
#include <C_CkStringBuilderW.h>
void ChilkatSample(void)
{
BOOL success;
HCkHttpW http;
HCkStringBuilderW sb;
success = FALSE;
http = CkHttpW_Create();
// Send the HTTP GET and return the content in a StringBuilder
sb = CkStringBuilderW_Create();
success = CkHttpW_QuickGetSb(http,L"https://www.chilkatsoft.com/helloWorld.json",sb);
if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
if (CkHttpW_getLastStatus(http) == 0) {
// Communications error. We did not get a response.
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
}
else {
wprintf(L"Response status code: %d\n",CkHttpW_getLastStatus(http));
wprintf(L"Response body error text:\n");
wprintf(L"%s\n",CkStringBuilderW_getAsString(sb));
}
CkHttpW_Dispose(http);
CkStringBuilderW_Dispose(sb);
return;
}
// The downloaded content:
wprintf(L"%s\n",CkStringBuilderW_getAsString(sb));
wprintf(L"Success\n");
CkHttpW_Dispose(http);
CkStringBuilderW_Dispose(sb);
}