decodeHeaders static method

ExtendedConnectRequest decodeHeaders(
  1. Uint8List bytes
)

Decode a QPACK-encoded field section into an ExtendedConnectRequest.

Implementation

static ExtendedConnectRequest decodeHeaders(Uint8List bytes) {
  final lines = QpackDecoder.decodeFieldLines(bytes);

  String protocol = '';
  String scheme = '';
  String authority = '';
  String path = '';
  final headers = <String, String>{};

  for (final line in lines) {
    switch (line.name) {
      case ':protocol':
        protocol = line.value;
      case ':scheme':
        scheme = line.value;
      case ':authority':
        authority = line.value;
      case ':path':
        path = line.value;
      case ':method':
        // ignored, always CONNECT
        break;
      default:
        headers[line.name] = line.value;
    }
  }

  return ExtendedConnectRequest(
    protocol: protocol,
    scheme: scheme,
    authority: authority,
    path: path,
    headers: headers,
  );
}