encodeHeaders method

Uint8List encodeHeaders({
  1. QpackEncoder? encoder,
})

Encode the request headers as a QPACK-encoded field section.

encoder may be used to emit dynamic table insertions on the QPACK encoder stream. When omitted, only the static table is used.

Implementation

Uint8List encodeHeaders({QpackEncoder? encoder}) {
  final lines = <({String name, String value})>[
    (name: ':method', value: 'CONNECT'),
    (name: ':scheme', value: scheme),
    (name: ':authority', value: authority),
    (name: ':path', value: path),
    (name: ':protocol', value: protocol),
  ];
  for (final entry in headers.entries) {
    lines.add((name: entry.key.toLowerCase(), value: entry.value));
  }
  if (encoder != null) {
    return encoder.encodeLines(lines);
  }
  return QpackEncoder.encodeFieldLines(lines);
}