C
C
Setting a HTTP Max Response Size
Demonstrates theMaxResponseSize property.
Chilkat C Downloads
#include <C_CkHttp.h>
void ChilkatSample(void)
{
BOOL success;
HCkHttp http;
unsigned long maxSz;
const char *xmlStr;
success = FALSE;
http = CkHttp_Create();
maxSz = 16384;
CkHttp_putMaxResponseSize(http,maxSz);
// Try to get something larger, such as hamlet.xml which is 279658 bytes
xmlStr = CkHttp_quickGetStr(http,"https://chilkatsoft.com/hamlet.xml");
if (CkHttp_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.
printf("%s\n",CkHttp_lastErrorText(http));
CkHttp_Dispose(http);
return;
}
printf("OK\n");
CkHttp_Dispose(http);
}