getHeaders method

List getHeaders(
  1. String name
)

Get the header/s of the given name. -param {String} name header name -returns {Array} Array with all the headers of the specified name.

Implementation

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

  if (headers != null) {
    for (dynamic header in headers) {
      result.add(header);
    }

    return result;
  } else {
    RegExp regexp = RegExp('^\\s*$name\\s*:', caseSensitive: false);

    for (dynamic header in extraHeaders) {
      if (regexp.hasMatch(header)) {
        result.add(header.substring(header.indexOf(':') + 1).trim());
      }
    }

    return result;
  }
}