copyWithoutRaw method

HttpHeaders copyWithoutRaw(
  1. String key
)

Removes a header from the headers. Returns a new instance of HttpHeaders without the key. Converts HttpHeaderMap to HttpHeaderRawMap.

Implementation

HttpHeaders copyWithoutRaw(String key) {
  key = key.toLowerCase();
  return switch (this) {
    HttpHeaderMap map => HttpHeaders.rawMap({
        for (final entry in map.map.entries)
          if (entry.key.httpName != key) entry.key.httpName: entry.value,
      }),
    HttpHeaderRawMap rawMap => HttpHeaders.rawMap({
        for (final entry in rawMap.map.entries)
          if (entry.key.toLowerCase() != key) entry.key: entry.value,
      }),
    HttpHeaderList list => HttpHeaders.list([
        for (final entry in list.list)
          if (entry.$1.toLowerCase() != key) entry,
      ]),
  };
}