(Unicode C) Setting a HTTP Max Response Size
Demonstrates the MaxResponseSize property.
#include <C_CkHttpW.h>
void ChilkatSample(void)
{
BOOL success;
HCkHttpW http;
unsigned long maxSz;
const wchar_t *xmlStr;
success = FALSE;
http = CkHttpW_Create();
maxSz = 16384;
CkHttpW_putMaxResponseSize(http,maxSz);
// Try to get something larger, such as hamlet.xml which is 279658 bytes
xmlStr = CkHttpW_quickGetStr(http,L"https://chilkatsoft.com/hamlet.xml");
if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
// If the LastErrorText contains the string "MaxResponseSize",
// then the HTTP request failed because the response body would've been larger than the max allowed response size.
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
return;
}
wprintf(L"OK\n");
CkHttpW_Dispose(http);
}
|