(client, request)
| 7244 | if (this[kHTTP2Session] != null) { |
| 7245 | this[kHTTP2Session].destroy(err); |
| 7246 | this[kHTTP2Session] = null; |
| 7247 | } |
| 7248 | util.destroy(this[kSocket], err); |
| 7249 | if (client[kRunningIdx] < client[kQueue].length) { |
| 7250 | const request = client[kQueue][client[kRunningIdx]]; |
| 7251 | client[kQueue][client[kRunningIdx]++] = null; |
| 7252 | util.errorRequest(client, request, err); |
| 7253 | client[kPendingIdx] = client[kRunningIdx]; |
| 7254 | } |
| 7255 | assert(client[kRunning] === 0); |
| 7256 | client.emit("disconnect", client[kUrl], [client], err); |
| 7257 | client[kResume](); |
| 7258 | } |
| 7259 | function shouldSendContentLength(method) { |
| 7260 | return method !== "GET" && method !== "HEAD" && method !== "OPTIONS" && method !== "TRACE" && method !== "CONNECT"; |
| 7261 | } |
| 7262 | function writeH2(client, request) { |
| 7263 | const session = client[kHTTP2Session]; |
| 7264 | const { method, path: path4, host, upgrade, expectContinue, signal, headers: reqHeaders } = request; |
| 7265 | let { body } = request; |
| 7266 | if (upgrade) { |
| 7267 | util.errorRequest(client, request, new Error("Upgrade not supported for H2")); |
| 7268 | return false; |
| 7269 | } |
| 7270 | const headers = {}; |
| 7271 | for (let n = 0; n < reqHeaders.length; n += 2) { |
| 7272 | const key = reqHeaders[n + 0]; |
| 7273 | const val = reqHeaders[n + 1]; |
| 7274 | if (Array.isArray(val)) { |
| 7275 | for (let i = 0; i < val.length; i++) { |
| 7276 | if (headers[key]) { |
| 7277 | headers[key] += `,${val[i]}`; |
| 7278 | } else { |
| 7279 | headers[key] = val[i]; |
| 7280 | } |
| 7281 | } |
| 7282 | } else { |
| 7283 | headers[key] = val; |
| 7284 | } |
| 7285 | } |
| 7286 | let stream; |
| 7287 | const { hostname, port } = client[kUrl]; |
| 7288 | headers[HTTP2_HEADER_AUTHORITY] = host || `${hostname}${port ? `:${port}` : ""}`; |
| 7289 | headers[HTTP2_HEADER_METHOD] = method; |
| 7290 | const abort = (err) => { |
| 7291 | if (request.aborted || request.completed) { |
| 7292 | return; |
| 7293 | } |
| 7294 | err = err || new RequestAbortedError(); |
| 7295 | util.errorRequest(client, request, err); |
| 7296 | if (stream != null) { |
| 7297 | util.destroy(stream, err); |
| 7298 | } |
| 7299 | util.destroy(body, err); |
| 7300 | client[kQueue][client[kRunningIdx]++] = null; |
| 7301 | client[kResume](); |
| 7302 | }; |
| 7303 | try { |
no test coverage detected