getHeader method

dynamic getHeader(
  1. String name
)

Get the value of the given header name at the given position. -param {String} name header name -returns {String|null} Returns the specified header, null if header doesn't exist.

Implementation

dynamic getHeader(String name) {
  List<dynamic>? headers = this.headers[utils.headerize(name)];

  if (headers != null) {
    if (headers[0] != null) {
      return headers[0];
    }
  } else {
    RegExp regexp = RegExp('^\\s*$name\\s*:', caseSensitive: false);
    for (dynamic header in extraHeaders) {
      if (regexp.hasMatch(header)) {
        return header.substring(header.indexOf(':') + 1).trim();
      }
    }
  }

  return null;
}