push method

Http2ResponseContext push(
  1. String path, {
  2. Map<String, String> headers = const {},
  3. String method = 'GET',
})

Pushes a resource to the client.

Implementation

Http2ResponseContext push(String path,
    {Map<String, String> headers = const {}, String method = 'GET'}) {
  var targetUri = _req!.uri!.replace(path: path);

  var h = <Header>[
    Header.ascii(':authority', targetUri.authority),
    Header.ascii(':method', method),
    Header.ascii(':path', targetUri.path),
    Header.ascii(':scheme', targetUri.scheme),
  ];

  for (var key in headers.keys) {
    h.add(Header.ascii(key, headers[key]!));
  }

  var s = stream.push(h);
  var r = Http2ResponseContext(app, s, _req)
    .._isPush = true
    .._targetUri = targetUri;
  _pushes.add(r);
  return r;
}