Sample code for 30+ languages & platforms
Objective-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 Objective-C Downloads

Objective-C
#import <CkoRest.h>
#import <CkoStream.h>

BOOL success = NO;

CkoRest *rest = [[CkoRest alloc] init];
BOOL bTls = YES;
BOOL bAutoReconnect = YES;
success = [rest Connect: @"example.com" port: [NSNumber numberWithInt: 443] tls: bTls autoReconnect: bAutoReconnect];
if (success == NO) {
    NSLog(@"%@",rest.LastErrorText);
    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.

CkoStream *respStream = [[CkoStream alloc] init];
respStream.SinkFile = @"qa_output/response_body.dat";
BOOL bAutoSetCharset = YES;
int expectedStatus = 200;
success = [rest SetResponseBodyStream: [NSNumber numberWithInt: expectedStatus] autoSetStreamCharset: bAutoSetCharset responseStream: respStream];
if (success == NO) {
    NSLog(@"%@",rest.LastErrorText);
    return;
}

//  Clear the response-stream destination previously configured, so subsequent full-request calls
//  return the response body normally instead of streaming it.
[rest ClearResponseBodyStream];

NSLog(@"%@",@"Response body streaming cleared.");