(client, socket)
| 8444 | } |
| 8445 | __name(closeRequestStream, "closeRequestStream"); |
| 8446 | function connectH2(client, socket) { |
| 8447 | client[kSocket] = socket; |
| 8448 | const http2InitialWindowSize = client[kHTTP2InitialWindowSize]; |
| 8449 | const http2ConnectionWindowSize = client[kHTTP2ConnectionWindowSize]; |
| 8450 | const session = http2.connect(client[kUrl], { |
| 8451 | createConnection: /* @__PURE__ */ __name(() => socket, "createConnection"), |
| 8452 | peerMaxConcurrentStreams: client[kMaxConcurrentStreams], |
| 8453 | settings: { |
| 8454 | // TODO(metcoder95): add support for PUSH |
| 8455 | enablePush: false, |
| 8456 | ...http2InitialWindowSize != null ? { initialWindowSize: http2InitialWindowSize } : null |
| 8457 | } |
| 8458 | }); |
| 8459 | client[kSocket] = socket; |
| 8460 | session[kOpenStreams] = 0; |
| 8461 | session[kClient] = client; |
| 8462 | session[kSocket] = socket; |
| 8463 | session[kHTTP2SessionState] = { |
| 8464 | idleTimeout: null, |
| 8465 | ping: { |
| 8466 | interval: client[kPingInterval] === 0 ? null : setInterval(onHttp2SendPing, client[kPingInterval], session).unref() |
| 8467 | } |
| 8468 | }; |
| 8469 | session[kReceivedGoAway] = false; |
| 8470 | session[kEnableConnectProtocol] = false; |
| 8471 | session[kRemoteSettings] = false; |
| 8472 | if (http2ConnectionWindowSize) { |
| 8473 | util.addListener(session, "connect", applyConnectionWindowSize.bind(session, http2ConnectionWindowSize)); |
| 8474 | } |
| 8475 | util.addListener(session, "error", onHttp2SessionError); |
| 8476 | util.addListener(session, "frameError", onHttp2FrameError); |
| 8477 | util.addListener(session, "end", onHttp2SessionEnd); |
| 8478 | util.addListener(session, "goaway", onHttp2SessionGoAway); |
| 8479 | util.addListener(session, "close", onHttp2SessionClose); |
| 8480 | util.addListener(session, "remoteSettings", onHttp2RemoteSettings); |
| 8481 | session.unref(); |
| 8482 | client[kHTTP2Session] = session; |
| 8483 | socket[kHTTP2Session] = session; |
| 8484 | util.addListener(socket, "error", onHttp2SocketError); |
| 8485 | util.addListener(socket, "end", onHttp2SocketEnd); |
| 8486 | util.addListener(socket, "close", onHttp2SocketClose); |
| 8487 | socket[kClosed] = false; |
| 8488 | socket.on("close", onSocketClose); |
| 8489 | return { |
| 8490 | version: "h2", |
| 8491 | defaultPipelining: Infinity, |
| 8492 | /** |
| 8493 | * @param {import('../core/request.js')} request |
| 8494 | * @returns {boolean} |
| 8495 | */ |
| 8496 | write(request) { |
| 8497 | return writeH2(client, request); |
| 8498 | }, |
| 8499 | /** |
| 8500 | * @returns {void} |
| 8501 | */ |
| 8502 | resume() { |
| 8503 | resumeH2(client); |
no test coverage detected