C
C
Clear a REST Response Body Stream Destination
See more REST Examples
Demonstrates Rest.ClearResponseBodyStream, which removes a response-stream destination previously configured with SetResponseBodyStream.
The file paths are relative to the application's current working directory. Absolute paths may also be used. Supply the paths appropriate to your own environment.
Background. Clearing the destination restores normal behavior, in which the full-request convenience methods return the response body rather than streaming it.
Chilkat C Downloads
#include <C_CkRest.h>
#include <C_CkStream.h>
void ChilkatSample(void)
{
BOOL success;
HCkRest rest;
BOOL bTls;
BOOL bAutoReconnect;
HCkStream respStream;
BOOL bAutoSetCharset;
int expectedStatus;
success = FALSE;
rest = CkRest_Create();
bTls = TRUE;
bAutoReconnect = TRUE;
success = CkRest_Connect(rest,"example.com",443,bTls,bAutoReconnect);
if (success == FALSE) {
printf("%s\n",CkRest_lastErrorText(rest));
CkRest_Dispose(rest);
return;
}
// The file paths are relative to the application's current working directory. Absolute paths
// may also be used. Supply the paths appropriate to your own environment.
respStream = CkStream_Create();
CkStream_putSinkFile(respStream,"qa_output/response_body.dat");
bAutoSetCharset = TRUE;
expectedStatus = 200;
success = CkRest_SetResponseBodyStream(rest,expectedStatus,bAutoSetCharset,respStream);
if (success == FALSE) {
printf("%s\n",CkRest_lastErrorText(rest));
CkRest_Dispose(rest);
CkStream_Dispose(respStream);
return;
}
// Clear the response-stream destination previously configured, so subsequent full-request calls
// return the response body normally instead of streaming it.
CkRest_ClearResponseBodyStream(rest);
printf("Response body streaming cleared.\n");
CkRest_Dispose(rest);
CkStream_Dispose(respStream);
}