Sample code for 30+ languages & platforms
Dart

Setting a HTTP Max Response Size

Demonstrates the MaxResponseSize property.

Chilkat Dart Downloads

Dart
import 'package:chilkat/chilkat.dart';

void main() {
  final http = CkHttp();

  final maxSz = 16384;
  http.maxResponseSize = maxSz;

  // Try to get something larger, such as hamlet.xml which is 279658 bytes
  final String xmlStr;
  try {
    xmlStr = http.quickGetStr('https://chilkatsoft.com/hamlet.xml');
  } on ChilkatException catch (e) {
    // 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.
    print(e.lastErrorText);
    return;
  }

  print('OK');
}