How to use the http2.connect function in http2

To help you get started, we’ve selected a few http2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github graalvm / graaljs / test / parallel / test-http2-respond-file-errors.js View on Github external
server.listen(0, common.mustCall(() => {
  const client = http2.connect(`http://localhost:${server.address().port}`);
  const req = client.request();

  req.on('close', common.mustCall(() => {
    client.close();
    server.close();
  }));
  req.end();
}));
github graalvm / graaljs / test / parallel / test-http2-respond-errors.js View on Github external
server.listen(0, common.mustCall(() => {
  const client = http2.connect(`http://localhost:${server.address().port}`);
  const req = client.request();

  req.on('end', common.mustCall(() => {
    client.close();
    server.close();
  }));
  req.resume();
  req.end();
}));
github graalvm / graaljs / test / parallel / test-http2-client-priority-before-connect.js View on Github external
server.listen(0, common.mustCall(() => {
  const client = h2.connect(`http://localhost:${server.address().port}`);
  const req = client.request();
  req.priority({});

  req.on('response', common.mustCall());
  req.resume();
  req.on('end', common.mustCall());
  req.on('close', common.mustCall(() => {
    server.close();
    client.close();
  }));
}));
github graalvm / graaljs / test / parallel / test-http2-compat-serverresponse-settimeout.js View on Github external
server.listen(0, common.mustCall(() => {
  const port = server.address().port;
  const client = http2.connect(`http://localhost:${port}`);
  const req = client.request({
    ':path': '/',
    ':method': 'GET',
    ':scheme': 'http',
    ':authority': `localhost:${port}`
  });
  req.on('end', common.mustCall(() => {
    client.close();
  }));
  req.resume();
  req.end();
}));
github graalvm / graaljs / test / parallel / test-http2-stream-client.js View on Github external
server.listen(0, common.mustCall(() => {
  const client = http2.connect(`http://localhost:${server.address().port}`);
  const req = client.request();
  req.resume();
  req.on('close', common.mustCall(() => {
    client.close();
    server.close();
  }));
}));
github dataform-co / dataform / tools / grpc-web-proxy / index.ts View on Github external
private async connectAndKeepAlive(backend: string) {
    while (!this.isShutdown) {
      if (!this.grpcClient || this.grpcClient.destroyed) {
        this.grpcClient = http2.connect(backend);
        this.grpcClient.on("connect", () => {
          console.info(`Successfully connected to backend: ${backend}`);
        });
        this.grpcClient.on("error", error => {
          console.error(`Failed to connect to backend: ${backend}\n${error}`);
        });
      }
      await new Promise(resolve => setTimeout(resolve, 1000));
    }
  }
github electron-userland / electron-builder / packages / electron-builder-lib / src / remoteBuilder / RemoteBuildManager.ts View on Github external
constructor(private readonly buildServiceEndpoint: string,
              private readonly projectInfoManager: ProjectInfoManager,
              private readonly unpackedDirectory: string,
              private readonly outDir: string,
              private readonly packager: PlatformPackager) {
    log.debug({endpoint: buildServiceEndpoint}, "connect to remote build service")
    this.client = connect(buildServiceEndpoint, getConnectOptions())
  }
github AndrewBarba / apns2 / lib / http2-client.js View on Github external
return new Promise((resolve, reject) => {
      let session = http2.connect(this._url)
      session.once('error', reject)
      session.once('socketError', reject)
      session.once('connect', () => {
        this._connected(session)
        resolve(this)
      })
    })
  }
github grantila / fetch-h2 / dist / lib / context.js View on Github external
const promise = new Promise((resolve, reject) => {
            session =
                http2_1.connect(origin, options, () => resolve(session));
            session.on('stream', pushHandler);
            session.once('close', () => reject(makeOkError(makeError())));
            session.once('timeout', () => reject(makeConnectionTimeout()));
            session.once('error', reject);
        });
        return { promise, session };

http2

An HTTP/2 client and server implementation

MIT
Latest version published 7 years ago

Package Health Score

53 / 100
Full package analysis