setHeader method

void setHeader(
  1. String name,
  2. dynamic value
)

Replace the the given header by the given value. -param {String} name header name -param {String | Array} value header value

Implementation

void setHeader(String name, dynamic value) {
  // Remove the header from extraHeaders if present.
  RegExp regexp = RegExp('^\\s*$name\\s*:', caseSensitive: false);

  for (int idx = 0; idx < extraHeaders.length; idx++) {
    if (regexp.hasMatch(extraHeaders[idx])) {
      extraHeaders.sublist(idx, 1);
    }
  }

  headers[utils.headerize(name)] = (value is List) ? value : <dynamic>[value];
}