Lines Matching full:code
58 <li><a href="module.html" class="nav-module">Modules: <code>node:module</code> API</a></li>
92 <li><a href="https://github.com/nodejs/node" class="nav-https-github-com-nodejs-node">Code reposito…
130 <li><a href="#class-http2session">Class: <code>Http2Session</code></a>
132 <li><a href="#http2session-and-sockets"><code>Http2Session</code> and sockets</a></li>
133 <li><a href="#event-close">Event: <code>'close'</code></a></li>
134 <li><a href="#event-connect">Event: <code>'connect'</code></a></li>
135 <li><a href="#event-error">Event: <code>'error'</code></a></li>
136 <li><a href="#event-frameerror">Event: <code>'frameError'</code></a></li>
137 <li><a href="#event-goaway">Event: <code>'goaway'</code></a></li>
138 <li><a href="#event-localsettings">Event: <code>'localSettings'</code></a></li>
139 <li><a href="#event-ping">Event: <code>'ping'</code></a></li>
140 <li><a href="#event-remotesettings">Event: <code>'remoteSettings'</code></a></li>
141 <li><a href="#event-stream">Event: <code>'stream'</code></a></li>
142 <li><a href="#event-timeout">Event: <code>'timeout'</code></a></li>
143 <li><a href="#http2sessionalpnprotocol"><code>http2session.alpnProtocol</code></a></li>
144 <li><a href="#http2sessionclosecallback"><code>http2session.close([callback])</code></a></li>
145 <li><a href="#http2sessionclosed"><code>http2session.closed</code></a></li>
146 <li><a href="#http2sessionconnecting"><code>http2session.connecting</code></a></li>
147 <li><a href="#http2sessiondestroyerror-code"><code>http2session.destroy([error][, code])</code></a>…
148 <li><a href="#http2sessiondestroyed"><code>http2session.destroyed</code></a></li>
149 <li><a href="#http2sessionencrypted"><code>http2session.encrypted</code></a></li>
150 …ssiongoawaycode-laststreamid-opaquedata"><code>http2session.goaway([code[, lastStreamID[, opaqueDa…
151 <li><a href="#http2sessionlocalsettings"><code>http2session.localSettings</code></a></li>
152 <li><a href="#http2sessionoriginset"><code>http2session.originSet</code></a></li>
153 <li><a href="#http2sessionpendingsettingsack"><code>http2session.pendingSettingsAck</code></a></li>
154 <li><a href="#http2sessionpingpayload-callback"><code>http2session.ping([payload, ]callback)</code>…
155 <li><a href="#http2sessionref"><code>http2session.ref()</code></a></li>
156 <li><a href="#http2sessionremotesettings"><code>http2session.remoteSettings</code></a></li>
157 …ref="#http2sessionsetlocalwindowsizewindowsize"><code>http2session.setLocalWindowSize(windowSize)<…
158 …i><a href="#http2sessionsettimeoutmsecs-callback"><code>http2session.setTimeout(msecs, callback)</…
159 <li><a href="#http2sessionsocket"><code>http2session.socket</code></a></li>
160 <li><a href="#http2sessionstate"><code>http2session.state</code></a></li>
161 … href="#http2sessionsettingssettings-callback"><code>http2session.settings([settings][, callback])…
162 <li><a href="#http2sessiontype"><code>http2session.type</code></a></li>
163 <li><a href="#http2sessionunref"><code>http2session.unref()</code></a></li>
166 <li><a href="#class-serverhttp2session">Class: <code>ServerHttp2Session</code></a>
168 …="#serverhttp2sessionaltsvcalt-originorstream"><code>serverhttp2session.altsvc(alt, originOrStream…
170 <li><a href="#serverhttp2sessionoriginorigins"><code>serverhttp2session.origin(...origins)</code></…
173 <li><a href="#class-clienthttp2session">Class: <code>ClientHttp2Session</code></a>
175 <li><a href="#event-altsvc">Event: <code>'altsvc'</code></a></li>
176 <li><a href="#event-origin">Event: <code>'origin'</code></a></li>
177 …ef="#clienthttp2sessionrequestheaders-options"><code>clienthttp2session.request(headers[, options]…
180 <li><a href="#class-http2stream">Class: <code>Http2Stream</code></a>
182 <li><a href="#http2stream-lifecycle"><code>Http2Stream</code> Lifecycle</a>
188 <li><a href="#event-aborted">Event: <code>'aborted'</code></a></li>
189 <li><a href="#event-close_1">Event: <code>'close'</code></a></li>
190 <li><a href="#event-error_1">Event: <code>'error'</code></a></li>
191 <li><a href="#event-frameerror_1">Event: <code>'frameError'</code></a></li>
192 <li><a href="#event-ready">Event: <code>'ready'</code></a></li>
193 <li><a href="#event-timeout_1">Event: <code>'timeout'</code></a></li>
194 <li><a href="#event-trailers">Event: <code>'trailers'</code></a></li>
195 <li><a href="#event-wanttrailers">Event: <code>'wantTrailers'</code></a></li>
196 <li><a href="#http2streamaborted"><code>http2stream.aborted</code></a></li>
197 <li><a href="#http2streambuffersize"><code>http2stream.bufferSize</code></a></li>
198 <li><a href="#http2streamclosecode-callback"><code>http2stream.close(code[, callback])</code></a></…
199 <li><a href="#http2streamclosed"><code>http2stream.closed</code></a></li>
200 <li><a href="#http2streamdestroyed"><code>http2stream.destroyed</code></a></li>
201 <li><a href="#http2streamendafterheaders"><code>http2stream.endAfterHeaders</code></a></li>
202 <li><a href="#http2streamid"><code>http2stream.id</code></a></li>
203 <li><a href="#http2streampending"><code>http2stream.pending</code></a></li>
204 <li><a href="#http2streampriorityoptions"><code>http2stream.priority(options)</code></a></li>
205 <li><a href="#http2streamrstcode"><code>http2stream.rstCode</code></a></li>
206 <li><a href="#http2streamsentheaders"><code>http2stream.sentHeaders</code></a></li>
207 <li><a href="#http2streamsentinfoheaders"><code>http2stream.sentInfoHeaders</code></a></li>
208 <li><a href="#http2streamsenttrailers"><code>http2stream.sentTrailers</code></a></li>
209 <li><a href="#http2streamsession"><code>http2stream.session</code></a></li>
210 …li><a href="#http2streamsettimeoutmsecs-callback"><code>http2stream.setTimeout(msecs, callback)</c…
211 <li><a href="#http2streamstate"><code>http2stream.state</code></a></li>
212 <li><a href="#http2streamsendtrailersheaders"><code>http2stream.sendTrailers(headers)</code></a></l…
215 <li><a href="#class-clienthttp2stream">Class: <code>ClientHttp2Stream</code></a>
217 <li><a href="#event-continue">Event: <code>'continue'</code></a></li>
218 <li><a href="#event-headers">Event: <code>'headers'</code></a></li>
219 <li><a href="#event-push">Event: <code>'push'</code></a></li>
220 <li><a href="#event-response">Event: <code>'response'</code></a></li>
223 <li><a href="#class-serverhttp2stream">Class: <code>ServerHttp2Stream</code></a>
225 <li><a href="#http2streamadditionalheadersheaders"><code>http2stream.additionalHeaders(headers)</co…
226 <li><a href="#http2streamheaderssent"><code>http2stream.headersSent</code></a></li>
227 <li><a href="#http2streampushallowed"><code>http2stream.pushAllowed</code></a></li>
228 …p2streampushstreamheaders-options-callback"><code>http2stream.pushStream(headers[, options], callb…
229 <li><a href="#http2streamrespondheaders-options"><code>http2stream.respond([headers[, options]])</c…
230 …http2streamrespondwithfdfd-headers-options"><code>http2stream.respondWithFD(fd[, headers[, options…
231 …treamrespondwithfilepath-headers-options"><code>http2stream.respondWithFile(path[, headers[, optio…
234 <li><a href="#class-http2server">Class: <code>Http2Server</code></a>
236 <li><a href="#event-checkcontinue">Event: <code>'checkContinue'</code></a></li>
237 <li><a href="#event-connection">Event: <code>'connection'</code></a></li>
238 <li><a href="#event-request">Event: <code>'request'</code></a></li>
239 <li><a href="#event-session">Event: <code>'session'</code></a></li>
240 <li><a href="#event-sessionerror">Event: <code>'sessionError'</code></a></li>
241 <li><a href="#event-stream_1">Event: <code>'stream'</code></a></li>
242 <li><a href="#event-timeout_2">Event: <code>'timeout'</code></a></li>
243 <li><a href="#serverclosecallback"><code>server.close([callback])</code></a></li>
244 <li><a href="#serversettimeoutmsecs-callback"><code>server.setTimeout([msecs][, callback])</code></…
245 <li><a href="#servertimeout"><code>server.timeout</code></a></li>
246 <li><a href="#serverupdatesettingssettings"><code>server.updateSettings([settings])</code></a></li>
249 <li><a href="#class-http2secureserver">Class: <code>Http2SecureServer</code></a>
251 <li><a href="#event-checkcontinue_1">Event: <code>'checkContinue'</code></a></li>
252 <li><a href="#event-connection_1">Event: <code>'connection'</code></a></li>
253 <li><a href="#event-request_1">Event: <code>'request'</code></a></li>
254 <li><a href="#event-session_1">Event: <code>'session'</code></a></li>
255 <li><a href="#event-sessionerror_1">Event: <code>'sessionError'</code></a></li>
256 <li><a href="#event-stream_2">Event: <code>'stream'</code></a></li>
257 <li><a href="#event-timeout_3">Event: <code>'timeout'</code></a></li>
258 <li><a href="#event-unknownprotocol">Event: <code>'unknownProtocol'</code></a></li>
259 <li><a href="#serverclosecallback_1"><code>server.close([callback])</code></a></li>
260 <li><a href="#serversettimeoutmsecs-callback_1"><code>server.setTimeout([msecs][, callback])</code>…
261 <li><a href="#servertimeout_1"><code>server.timeout</code></a></li>
262 <li><a href="#serverupdatesettingssettings_1"><code>server.updateSettings([settings])</code></a></l…
265 …"#http2createserveroptions-onrequesthandler"><code>http2.createServer([options][, onRequestHandler…
266 …reatesecureserveroptions-onrequesthandler"><code>http2.createSecureServer(options[, onRequestHandl…
267 …ref="#http2connectauthority-options-listener"><code>http2.connect(authority[, options][, listener]…
268 <li><a href="#http2constants"><code>http2.constants</code></a>
270 …ror-codes-for-rst_stream-and-goaway">Error codes for <code>RST_STREAM</code> and <code>GOAWAY</cod…
273 <li><a href="#http2getdefaultsettings"><code>http2.getDefaultSettings()</code></a></li>
274 <li><a href="#http2getpackedsettingssettings"><code>http2.getPackedSettings([settings])</code></a><…
275 <li><a href="#http2getunpackedsettingsbuf"><code>http2.getUnpackedSettings(buf)</code></a></li>
276 <li><a href="#http2sensitiveheaders"><code>http2.sensitiveHeaders</code></a></li>
286 <li><a href="#supporting-the-connect-method">Supporting the <code>CONNECT</code> method</a></li>
287 <li><a href="#the-extended-connect-protocol">The extended <code>CONNECT</code> protocol</a></li>
293 <li><a href="#class-http2http2serverrequest">Class: <code>http2.Http2ServerRequest</code></a>
295 <li><a href="#event-aborted_1">Event: <code>'aborted'</code></a></li>
296 <li><a href="#event-close_2">Event: <code>'close'</code></a></li>
297 <li><a href="#requestaborted"><code>request.aborted</code></a></li>
298 <li><a href="#requestauthority"><code>request.authority</code></a></li>
299 <li><a href="#requestcomplete"><code>request.complete</code></a></li>
300 <li><span class="stability_0"><a href="#requestconnection"><code>request.connection</code></a></spa…
301 <li><a href="#requestdestroyerror"><code>request.destroy([error])</code></a></li>
302 <li><a href="#requestheaders"><code>request.headers</code></a></li>
303 <li><a href="#requesthttpversion"><code>request.httpVersion</code></a></li>
304 <li><a href="#requestmethod"><code>request.method</code></a></li>
305 <li><a href="#requestrawheaders"><code>request.rawHeaders</code></a></li>
306 <li><a href="#requestrawtrailers"><code>request.rawTrailers</code></a></li>
307 <li><a href="#requestscheme"><code>request.scheme</code></a></li>
308 <li><a href="#requestsettimeoutmsecs-callback"><code>request.setTimeout(msecs, callback)</code></a>…
309 <li><a href="#requestsocket"><code>request.socket</code></a></li>
310 <li><a href="#requeststream"><code>request.stream</code></a></li>
311 <li><a href="#requesttrailers"><code>request.trailers</code></a></li>
312 <li><a href="#requesturl"><code>request.url</code></a></li>
315 <li><a href="#class-http2http2serverresponse">Class: <code>http2.Http2ServerResponse</code></a>
317 <li><a href="#event-close_3">Event: <code>'close'</code></a></li>
318 <li><a href="#event-finish">Event: <code>'finish'</code></a></li>
319 <li><a href="#responseaddtrailersheaders"><code>response.addTrailers(headers)</code></a></li>
320 <li><span class="stability_0"><a href="#responseconnection"><code>response.connection</code></a></s…
321 …="#responsecreatepushresponseheaders-callback"><code>response.createPushResponse(headers, callback…
322 …li><a href="#responseenddata-encoding-callback"><code>response.end([data[, encoding]][, callback])…
323 <li><span class="stability_0"><a href="#responsefinished"><code>response.finished</code></a></span>…
324 <li><a href="#responsegetheadername"><code>response.getHeader(name)</code></a></li>
325 <li><a href="#responsegetheadernames"><code>response.getHeaderNames()</code></a></li>
326 <li><a href="#responsegetheaders"><code>response.getHeaders()</code></a></li>
327 <li><a href="#responsehasheadername"><code>response.hasHeader(name)</code></a></li>
328 <li><a href="#responseheaderssent"><code>response.headersSent</code></a></li>
329 <li><a href="#responseremoveheadername"><code>response.removeHeader(name)</code></a></li>
330 <li><a href="#responsereq"><code>response.req</code></a></li>
331 <li><a href="#responsesenddate"><code>response.sendDate</code></a></li>
332 <li><a href="#responsesetheadername-value"><code>response.setHeader(name, value)</code></a></li>
333 <li><a href="#responsesettimeoutmsecs-callback"><code>response.setTimeout(msecs[, callback])</code>…
334 <li><a href="#responsesocket"><code>response.socket</code></a></li>
335 <li><a href="#responsestatuscode"><code>response.statusCode</code></a></li>
336 <li><a href="#responsestatusmessage"><code>response.statusMessage</code></a></li>
337 <li><a href="#responsestream"><code>response.stream</code></a></li>
338 <li><a href="#responsewritableended"><code>response.writableEnded</code></a></li>
339 …a href="#responsewritechunk-encoding-callback"><code>response.write(chunk[, encoding][, callback])…
340 <li><a href="#responsewritecontinue"><code>response.writeContinue()</code></a></li>
341 <li><a href="#responsewriteearlyhintshints"><code>response.writeEarlyHints(hints)</code></a></li>
342 …iteheadstatuscode-statusmessage-headers"><code>response.writeHead(statusCode[, statusMessage][, he…
348 <li><a href="#note-on-authority-and-host">Note on <code>:authority</code> and <code>host</code></a>…
401 <li><a href="module.html" class="nav-module">Modules: <code>node:module</code> API</a></li>
435 <li><a href="https://github.com/nodejs/node" class="nav-https-github-com-nodejs-node">Code reposito…
491 <li><a href="#class-http2session">Class: <code>Http2Session</code></a>
493 <li><a href="#http2session-and-sockets"><code>Http2Session</code> and sockets</a></li>
494 <li><a href="#event-close">Event: <code>'close'</code></a></li>
495 <li><a href="#event-connect">Event: <code>'connect'</code></a></li>
496 <li><a href="#event-error">Event: <code>'error'</code></a></li>
497 <li><a href="#event-frameerror">Event: <code>'frameError'</code></a></li>
498 <li><a href="#event-goaway">Event: <code>'goaway'</code></a></li>
499 <li><a href="#event-localsettings">Event: <code>'localSettings'</code></a></li>
500 <li><a href="#event-ping">Event: <code>'ping'</code></a></li>
501 <li><a href="#event-remotesettings">Event: <code>'remoteSettings'</code></a></li>
502 <li><a href="#event-stream">Event: <code>'stream'</code></a></li>
503 <li><a href="#event-timeout">Event: <code>'timeout'</code></a></li>
504 <li><a href="#http2sessionalpnprotocol"><code>http2session.alpnProtocol</code></a></li>
505 <li><a href="#http2sessionclosecallback"><code>http2session.close([callback])</code></a></li>
506 <li><a href="#http2sessionclosed"><code>http2session.closed</code></a></li>
507 <li><a href="#http2sessionconnecting"><code>http2session.connecting</code></a></li>
508 <li><a href="#http2sessiondestroyerror-code"><code>http2session.destroy([error][, code])</code></a>…
509 <li><a href="#http2sessiondestroyed"><code>http2session.destroyed</code></a></li>
510 <li><a href="#http2sessionencrypted"><code>http2session.encrypted</code></a></li>
511 …ssiongoawaycode-laststreamid-opaquedata"><code>http2session.goaway([code[, lastStreamID[, opaqueDa…
512 <li><a href="#http2sessionlocalsettings"><code>http2session.localSettings</code></a></li>
513 <li><a href="#http2sessionoriginset"><code>http2session.originSet</code></a></li>
514 <li><a href="#http2sessionpendingsettingsack"><code>http2session.pendingSettingsAck</code></a></li>
515 <li><a href="#http2sessionpingpayload-callback"><code>http2session.ping([payload, ]callback)</code>…
516 <li><a href="#http2sessionref"><code>http2session.ref()</code></a></li>
517 <li><a href="#http2sessionremotesettings"><code>http2session.remoteSettings</code></a></li>
518 …ref="#http2sessionsetlocalwindowsizewindowsize"><code>http2session.setLocalWindowSize(windowSize)<…
519 …i><a href="#http2sessionsettimeoutmsecs-callback"><code>http2session.setTimeout(msecs, callback)</…
520 <li><a href="#http2sessionsocket"><code>http2session.socket</code></a></li>
521 <li><a href="#http2sessionstate"><code>http2session.state</code></a></li>
522 … href="#http2sessionsettingssettings-callback"><code>http2session.settings([settings][, callback])…
523 <li><a href="#http2sessiontype"><code>http2session.type</code></a></li>
524 <li><a href="#http2sessionunref"><code>http2session.unref()</code></a></li>
527 <li><a href="#class-serverhttp2session">Class: <code>ServerHttp2Session</code></a>
529 …="#serverhttp2sessionaltsvcalt-originorstream"><code>serverhttp2session.altsvc(alt, originOrStream…
531 <li><a href="#serverhttp2sessionoriginorigins"><code>serverhttp2session.origin(...origins)</code></…
534 <li><a href="#class-clienthttp2session">Class: <code>ClientHttp2Session</code></a>
536 <li><a href="#event-altsvc">Event: <code>'altsvc'</code></a></li>
537 <li><a href="#event-origin">Event: <code>'origin'</code></a></li>
538 …ef="#clienthttp2sessionrequestheaders-options"><code>clienthttp2session.request(headers[, options]…
541 <li><a href="#class-http2stream">Class: <code>Http2Stream</code></a>
543 <li><a href="#http2stream-lifecycle"><code>Http2Stream</code> Lifecycle</a>
549 <li><a href="#event-aborted">Event: <code>'aborted'</code></a></li>
550 <li><a href="#event-close_1">Event: <code>'close'</code></a></li>
551 <li><a href="#event-error_1">Event: <code>'error'</code></a></li>
552 <li><a href="#event-frameerror_1">Event: <code>'frameError'</code></a></li>
553 <li><a href="#event-ready">Event: <code>'ready'</code></a></li>
554 <li><a href="#event-timeout_1">Event: <code>'timeout'</code></a></li>
555 <li><a href="#event-trailers">Event: <code>'trailers'</code></a></li>
556 <li><a href="#event-wanttrailers">Event: <code>'wantTrailers'</code></a></li>
557 <li><a href="#http2streamaborted"><code>http2stream.aborted</code></a></li>
558 <li><a href="#http2streambuffersize"><code>http2stream.bufferSize</code></a></li>
559 <li><a href="#http2streamclosecode-callback"><code>http2stream.close(code[, callback])</code></a></…
560 <li><a href="#http2streamclosed"><code>http2stream.closed</code></a></li>
561 <li><a href="#http2streamdestroyed"><code>http2stream.destroyed</code></a></li>
562 <li><a href="#http2streamendafterheaders"><code>http2stream.endAfterHeaders</code></a></li>
563 <li><a href="#http2streamid"><code>http2stream.id</code></a></li>
564 <li><a href="#http2streampending"><code>http2stream.pending</code></a></li>
565 <li><a href="#http2streampriorityoptions"><code>http2stream.priority(options)</code></a></li>
566 <li><a href="#http2streamrstcode"><code>http2stream.rstCode</code></a></li>
567 <li><a href="#http2streamsentheaders"><code>http2stream.sentHeaders</code></a></li>
568 <li><a href="#http2streamsentinfoheaders"><code>http2stream.sentInfoHeaders</code></a></li>
569 <li><a href="#http2streamsenttrailers"><code>http2stream.sentTrailers</code></a></li>
570 <li><a href="#http2streamsession"><code>http2stream.session</code></a></li>
571 …li><a href="#http2streamsettimeoutmsecs-callback"><code>http2stream.setTimeout(msecs, callback)</c…
572 <li><a href="#http2streamstate"><code>http2stream.state</code></a></li>
573 <li><a href="#http2streamsendtrailersheaders"><code>http2stream.sendTrailers(headers)</code></a></l…
576 <li><a href="#class-clienthttp2stream">Class: <code>ClientHttp2Stream</code></a>
578 <li><a href="#event-continue">Event: <code>'continue'</code></a></li>
579 <li><a href="#event-headers">Event: <code>'headers'</code></a></li>
580 <li><a href="#event-push">Event: <code>'push'</code></a></li>
581 <li><a href="#event-response">Event: <code>'response'</code></a></li>
584 <li><a href="#class-serverhttp2stream">Class: <code>ServerHttp2Stream</code></a>
586 <li><a href="#http2streamadditionalheadersheaders"><code>http2stream.additionalHeaders(headers)</co…
587 <li><a href="#http2streamheaderssent"><code>http2stream.headersSent</code></a></li>
588 <li><a href="#http2streampushallowed"><code>http2stream.pushAllowed</code></a></li>
589 …p2streampushstreamheaders-options-callback"><code>http2stream.pushStream(headers[, options], callb…
590 <li><a href="#http2streamrespondheaders-options"><code>http2stream.respond([headers[, options]])</c…
591 …http2streamrespondwithfdfd-headers-options"><code>http2stream.respondWithFD(fd[, headers[, options…
592 …treamrespondwithfilepath-headers-options"><code>http2stream.respondWithFile(path[, headers[, optio…
595 <li><a href="#class-http2server">Class: <code>Http2Server</code></a>
597 <li><a href="#event-checkcontinue">Event: <code>'checkContinue'</code></a></li>
598 <li><a href="#event-connection">Event: <code>'connection'</code></a></li>
599 <li><a href="#event-request">Event: <code>'request'</code></a></li>
600 <li><a href="#event-session">Event: <code>'session'</code></a></li>
601 <li><a href="#event-sessionerror">Event: <code>'sessionError'</code></a></li>
602 <li><a href="#event-stream_1">Event: <code>'stream'</code></a></li>
603 <li><a href="#event-timeout_2">Event: <code>'timeout'</code></a></li>
604 <li><a href="#serverclosecallback"><code>server.close([callback])</code></a></li>
605 <li><a href="#serversettimeoutmsecs-callback"><code>server.setTimeout([msecs][, callback])</code></…
606 <li><a href="#servertimeout"><code>server.timeout</code></a></li>
607 <li><a href="#serverupdatesettingssettings"><code>server.updateSettings([settings])</code></a></li>
610 <li><a href="#class-http2secureserver">Class: <code>Http2SecureServer</code></a>
612 <li><a href="#event-checkcontinue_1">Event: <code>'checkContinue'</code></a></li>
613 <li><a href="#event-connection_1">Event: <code>'connection'</code></a></li>
614 <li><a href="#event-request_1">Event: <code>'request'</code></a></li>
615 <li><a href="#event-session_1">Event: <code>'session'</code></a></li>
616 <li><a href="#event-sessionerror_1">Event: <code>'sessionError'</code></a></li>
617 <li><a href="#event-stream_2">Event: <code>'stream'</code></a></li>
618 <li><a href="#event-timeout_3">Event: <code>'timeout'</code></a></li>
619 <li><a href="#event-unknownprotocol">Event: <code>'unknownProtocol'</code></a></li>
620 <li><a href="#serverclosecallback_1"><code>server.close([callback])</code></a></li>
621 <li><a href="#serversettimeoutmsecs-callback_1"><code>server.setTimeout([msecs][, callback])</code>…
622 <li><a href="#servertimeout_1"><code>server.timeout</code></a></li>
623 <li><a href="#serverupdatesettingssettings_1"><code>server.updateSettings([settings])</code></a></l…
626 …"#http2createserveroptions-onrequesthandler"><code>http2.createServer([options][, onRequestHandler…
627 …reatesecureserveroptions-onrequesthandler"><code>http2.createSecureServer(options[, onRequestHandl…
628 …ref="#http2connectauthority-options-listener"><code>http2.connect(authority[, options][, listener]…
629 <li><a href="#http2constants"><code>http2.constants</code></a>
631 …ror-codes-for-rst_stream-and-goaway">Error codes for <code>RST_STREAM</code> and <code>GOAWAY</cod…
634 <li><a href="#http2getdefaultsettings"><code>http2.getDefaultSettings()</code></a></li>
635 <li><a href="#http2getpackedsettingssettings"><code>http2.getPackedSettings([settings])</code></a><…
636 <li><a href="#http2getunpackedsettingsbuf"><code>http2.getUnpackedSettings(buf)</code></a></li>
637 <li><a href="#http2sensitiveheaders"><code>http2.sensitiveHeaders</code></a></li>
647 <li><a href="#supporting-the-connect-method">Supporting the <code>CONNECT</code> method</a></li>
648 <li><a href="#the-extended-connect-protocol">The extended <code>CONNECT</code> protocol</a></li>
654 <li><a href="#class-http2http2serverrequest">Class: <code>http2.Http2ServerRequest</code></a>
656 <li><a href="#event-aborted_1">Event: <code>'aborted'</code></a></li>
657 <li><a href="#event-close_2">Event: <code>'close'</code></a></li>
658 <li><a href="#requestaborted"><code>request.aborted</code></a></li>
659 <li><a href="#requestauthority"><code>request.authority</code></a></li>
660 <li><a href="#requestcomplete"><code>request.complete</code></a></li>
661 <li><span class="stability_0"><a href="#requestconnection"><code>request.connection</code></a></spa…
662 <li><a href="#requestdestroyerror"><code>request.destroy([error])</code></a></li>
663 <li><a href="#requestheaders"><code>request.headers</code></a></li>
664 <li><a href="#requesthttpversion"><code>request.httpVersion</code></a></li>
665 <li><a href="#requestmethod"><code>request.method</code></a></li>
666 <li><a href="#requestrawheaders"><code>request.rawHeaders</code></a></li>
667 <li><a href="#requestrawtrailers"><code>request.rawTrailers</code></a></li>
668 <li><a href="#requestscheme"><code>request.scheme</code></a></li>
669 <li><a href="#requestsettimeoutmsecs-callback"><code>request.setTimeout(msecs, callback)</code></a>…
670 <li><a href="#requestsocket"><code>request.socket</code></a></li>
671 <li><a href="#requeststream"><code>request.stream</code></a></li>
672 <li><a href="#requesttrailers"><code>request.trailers</code></a></li>
673 <li><a href="#requesturl"><code>request.url</code></a></li>
676 <li><a href="#class-http2http2serverresponse">Class: <code>http2.Http2ServerResponse</code></a>
678 <li><a href="#event-close_3">Event: <code>'close'</code></a></li>
679 <li><a href="#event-finish">Event: <code>'finish'</code></a></li>
680 <li><a href="#responseaddtrailersheaders"><code>response.addTrailers(headers)</code></a></li>
681 <li><span class="stability_0"><a href="#responseconnection"><code>response.connection</code></a></s…
682 …="#responsecreatepushresponseheaders-callback"><code>response.createPushResponse(headers, callback…
683 …li><a href="#responseenddata-encoding-callback"><code>response.end([data[, encoding]][, callback])…
684 <li><span class="stability_0"><a href="#responsefinished"><code>response.finished</code></a></span>…
685 <li><a href="#responsegetheadername"><code>response.getHeader(name)</code></a></li>
686 <li><a href="#responsegetheadernames"><code>response.getHeaderNames()</code></a></li>
687 <li><a href="#responsegetheaders"><code>response.getHeaders()</code></a></li>
688 <li><a href="#responsehasheadername"><code>response.hasHeader(name)</code></a></li>
689 <li><a href="#responseheaderssent"><code>response.headersSent</code></a></li>
690 <li><a href="#responseremoveheadername"><code>response.removeHeader(name)</code></a></li>
691 <li><a href="#responsereq"><code>response.req</code></a></li>
692 <li><a href="#responsesenddate"><code>response.sendDate</code></a></li>
693 <li><a href="#responsesetheadername-value"><code>response.setHeader(name, value)</code></a></li>
694 <li><a href="#responsesettimeoutmsecs-callback"><code>response.setTimeout(msecs[, callback])</code>…
695 <li><a href="#responsesocket"><code>response.socket</code></a></li>
696 <li><a href="#responsestatuscode"><code>response.statusCode</code></a></li>
697 <li><a href="#responsestatusmessage"><code>response.statusMessage</code></a></li>
698 <li><a href="#responsestream"><code>response.stream</code></a></li>
699 <li><a href="#responsewritableended"><code>response.writableEnded</code></a></li>
700 …a href="#responsewritechunk-encoding-callback"><code>response.write(chunk[, encoding][, callback])…
701 <li><a href="#responsewritecontinue"><code>response.writeContinue()</code></a></li>
702 <li><a href="#responsewriteearlyhintshints"><code>response.writeEarlyHints(hints)</code></a></li>
703 …iteheadstatuscode-statusmessage-headers"><code>response.writeHead(statusCode[, statusMessage][, he…
709 <li><a href="#note-on-authority-and-host">Note on <code>:authority</code> and <code>host</code></a>…
721 <td><p>Requests with the <code>host</code> header (with or without <code>:authority</code>) can now…
733 <p><strong>Source Code:</strong> <a href="https://github.com/nodejs/node/blob/v18.18.2/lib/http2.js…
734 <p>The <code>node:http2</code> module provides an implementation of the <a href="https://tools.ietf…
736 …code class="language-js"><span class="hljs-keyword">const</span> http2 = <span class="hljs-built_i…
739 <code>node:crypto</code> module. In such cases, attempting to <code>import</code> from <code>node:h…
740 calling <code>require('node:http2')</code> will result in an error being thrown.</p>
742 <pre><code class="language-js cjs"><span class="hljs-keyword">let</span> http2;
747 }</code> <button class="copy-button">copy</button></pre>
748 <p>When using the lexical ESM <code>import</code> keyword, the error can only be
749 caught if a handler for <code>process.on('uncaughtException')</code> is registered
752 <p>When using ESM, if there is a chance that the code may be run on a build
754 …avaScript/Reference/Operators/import"><code>import()</code></a> function instead of the lexical <c…
755 <pre><code class="language-js mjs"><span class="hljs-keyword">let</span> http2;
760 }</code> <button class="copy-button">copy</button></pre>
766 <p>The <code>http2</code> Core API is much more symmetric between client and server than the
767 <code>http</code> API. For instance, most events, like <code>'error'</code>, <code>'connect'</code>…
768 <code>'stream'</code>, can be emitted either by client-side code or server-side code.</p>
773 <a href="#http2createsecureserveroptions-onrequesthandler"><code>http2.createSecureServer()</code><…
775 <pre><code class="language-js"><span class="hljs-keyword">const</span> http2 = <span class="hljs-bu…
793 …s-title function_">listen</span>(<span class="hljs-number">8443</span>);</code> <button class="cop…
795 <pre><code class="language-bash">openssl req -x509 -newkey rsa:2048 -nodes -sha256 -subj <span clas…
796 …-keyout localhost-privkey.pem -out localhost-cert.pem</code> <button class="copy-button">copy</but…
799 <pre><code class="language-js"><span class="hljs-keyword">const</span> http2 = <span class="hljs-bu…
821 req.<span class="hljs-title function_">end</span>();</code> <button class="copy-button">copy</butto…
822 <h4>Class: <code>Http2Session</code><span><a class="mark" href="#class-http2session" id="class-http…
829 <p>Instances of the <code>http2.Http2Session</code> class represent an active communications
831 intended to be constructed directly by user code.</p>
832 <p>Each <code>Http2Session</code> instance will exhibit slightly different behaviors
834 <code>http2session.type</code> property can be used to determine the mode in which an
835 <code>Http2Session</code> is operating. On the server side, user code should rarely
836 have occasion to work with the <code>Http2Session</code> object directly, with most
837 actions typically taken through interactions with either the <code>Http2Server</code> or
838 <code>Http2Stream</code> objects.</p>
839 <p>User code will not create <code>Http2Session</code> instances directly. Server-side
840 <code>Http2Session</code> instances are created by the <code>Http2Server</code> instance when a
841 new HTTP/2 connection is received. Client-side <code>Http2Session</code> instances are
842 created using the <code>http2.connect()</code> method.</p>
843 <h5><code>Http2Session</code> and sockets<span><a class="mark" href="#http2session-and-sockets" id=…
844 <p>Every <code>Http2Session</code> instance is associated with exactly one <a href="net.html#class-…
845 …ef="tls.html#class-tlstlssocket"><code>tls.TLSSocket</code></a> when it is created. When either th…
846 <code>Http2Session</code> are destroyed, both will be destroyed.</p>
848 by the HTTP/2 protocol, it is not recommended for user code to read data from
849 or write data to a <code>Socket</code> instance bound to a <code>Http2Session</code>. Doing so can
852 <p>Once a <code>Socket</code> has been bound to an <code>Http2Session</code>, user code should rely
853 solely on the API of the <code>Http2Session</code>.</p>
854 <h5>Event: <code>'close'</code><span><a class="mark" href="#event-close" id="event-close">#</a></sp…
858 <p>The <code>'close'</code> event is emitted once the <code>Http2Session</code> has been destroyed.…
860 <h5>Event: <code>'connect'</code><span><a class="mark" href="#event-connect" id="event-connect">#</…
865 <li><code>session</code> <a href="http2.html#class-http2session" class="type"><Http2Session></…
866 <li><code>socket</code> <a href="net.html#class-netsocket" class="type"><net.Socket></a></li>
868 <p>The <code>'connect'</code> event is emitted once the <code>Http2Session</code> has been successf…
870 <p>User code will typically not listen for this event directly.</p>
871 <h5>Event: <code>'error'</code><span><a class="mark" href="#event-error" id="event-error">#</a></sp…
876 <li><code>error</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/G…
878 <p>The <code>'error'</code> event is emitted when an error occurs during the processing of
879 an <code>Http2Session</code>.</p>
880 <h5>Event: <code>'frameError'</code><span><a class="mark" href="#event-frameerror" id="event-framee…
885 <li><code>type</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structu…
886 …code>code</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#…
887 …code>id</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Nu…
890 <p>The <code>'frameError'</code> event is emitted when an error occurs while attempting to
892 with a specific <code>Http2Stream</code>, an attempt to emit a <code>'frameError'</code> event on t…
893 <code>Http2Stream</code> is made.</p>
894 <p>If the <code>'frameError'</code> event is associated with a stream, the stream will be
895 closed and destroyed immediately following the <code>'frameError'</code> event. If the
896 event is not associated with a stream, the <code>Http2Session</code> will be shut down
897 immediately following the <code>'frameError'</code> event.</p>
898 <h5>Event: <code>'goaway'</code><span><a class="mark" href="#event-goaway" id="event-goaway">#</a><…
903 …code>errorCode</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_struct…
904 <li><code>lastStreamID</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data…
905 processed (or <code>0</code> if no ID is specified).</li>
906 …code>opaqueData</code> <a href="buffer.html#class-buffer" class="type"><Buffer></a> If additi…
907 frame, a <code>Buffer</code> instance will be passed containing that data.</li>
909 <p>The <code>'goaway'</code> event is emitted when a <code>GOAWAY</code> frame is received.</p>
910 <p>The <code>Http2Session</code> instance will be shut down automatically when the <code>'goaway'</…
912 <h5>Event: <code>'localSettings'</code><span><a class="mark" href="#event-localsettings" id="event-…
917 <li><code>settings</code> <a href="http2.html#settings-object" class="type"><HTTP/2 Settings O…
919 <p>The <code>'localSettings'</code> event is emitted when an acknowledgment <code>SETTINGS</code> f…
921 <p>When using <code>http2session.settings()</code> to submit new settings, the modified
922 settings do not take effect until the <code>'localSettings'</code> event is emitted.</p>
923 <pre><code class="language-js">session.<span class="hljs-title function_">settings</span>({ <span c…
927 });</code> <button class="copy-button">copy</button></pre>
928 <h5>Event: <code>'ping'</code><span><a class="mark" href="#event-ping" id="event-ping">#</a></span>…
933 <li><code>payload</code> <a href="buffer.html#class-buffer" class="type"><Buffer></a> The <cod…
935 <p>The <code>'ping'</code> event is emitted whenever a <code>PING</code> frame is received from the
937 <h5>Event: <code>'remoteSettings'</code><span><a class="mark" href="#event-remotesettings" id="even…
942 <li><code>settings</code> <a href="http2.html#settings-object" class="type"><HTTP/2 Settings O…
944 <p>The <code>'remoteSettings'</code> event is emitted when a new <code>SETTINGS</code> frame is rec…
946 <pre><code class="language-js">session.<span class="hljs-title function_">on</span>(<span class="hl…
948 });</code> <button class="copy-button">copy</button></pre>
949 <h5>Event: <code>'stream'</code><span><a class="mark" href="#event-stream" id="event-stream">#</a><…
954 <li><code>stream</code> <a href="http2.html#class-http2stream" class="type"><Http2Stream></a> …
955 <li><code>headers</code> <a href="http2.html#headers-object" class="type"><HTTP/2 Headers Obje…
956 <li><code>flags</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_struct…
957 <li><code>rawHeaders</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refere…
960 <p>The <code>'stream'</code> event is emitted when a new <code>Http2Stream</code> is created.</p>
961 <pre><code class="language-js"><span class="hljs-keyword">const</span> http2 = <span class="hljs-bu…
972 });</code> <button class="copy-button">copy</button></pre>
973 <p>On the server side, user code will typically not listen for this event directly,
974 and would instead register a handler for the <code>'stream'</code> event emitted by the
975 <code>net.Server</code> or <code>tls.Server</code> instances returned by <code>http2.createServer()…
976 <code>http2.createSecureServer()</code>, respectively, as in the example below:</p>
977 <pre><code class="language-js"><span class="hljs-keyword">const</span> http2 = <span class="hljs-bu…
991 …s-title function_">listen</span>(<span class="hljs-number">8000</span>);</code> <button class="cop…
995 <h5>Event: <code>'timeout'</code><span><a class="mark" href="#event-timeout" id="event-timeout">#</…
999 <p>After the <code>http2session.setTimeout()</code> method is used to set the timeout period
1000 for this <code>Http2Session</code>, the <code>'timeout'</code> event is emitted if there is no
1001 activity on the <code>Http2Session</code> after the configured number of milliseconds.
1003 <pre><code class="language-js">session.<span class="hljs-built_in">setTimeout</span>(<span class="h…
1004 …-function">() =></span> { <span class="hljs-comment">/* .. */</span> });</code> <button class="cop…
1005 <h5><code>http2session.alpnProtocol</code><span><a class="mark" href="#http2sessionalpnprotocol" id…
1012 <p>Value will be <code>undefined</code> if the <code>Http2Session</code> is not yet connected to a
1013 socket, <code>h2c</code> if the <code>Http2Session</code> is not connected to a <code>TLSSocket</co…
1014 will return the value of the connected <code>TLSSocket</code>'s own <code>alpnProtocol</code>
1016 <h5><code>http2session.close([callback])</code><span><a class="mark" href="#http2sessionclosecallba…
1021 <li><code>callback</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Referenc…
1023 <p>Gracefully closes the <code>Http2Session</code>, allowing any existing streams to
1024 complete on their own and preventing new <code>Http2Stream</code> instances from being
1025 created. Once closed, <code>http2session.destroy()</code> <em>might</em> be called if there
1026 are no open <code>Http2Stream</code> instances.</p>
1027 <p>If specified, the <code>callback</code> function is registered as a handler for the
1028 <code>'close'</code> event.</p>
1029 <h5><code>http2session.closed</code><span><a class="mark" href="#http2sessionclosed" id="http2sessi…
1036 <p>Will be <code>true</code> if this <code>Http2Session</code> instance has been closed, otherwise
1037 <code>false</code>.</p>
1038 <h5><code>http2session.connecting</code><span><a class="mark" href="#http2sessionconnecting" id="ht…
1045 <p>Will be <code>true</code> if this <code>Http2Session</code> instance is still connecting, will b…
1046 to <code>false</code> before emitting <code>connect</code> event and/or calling the <code>http2.con…
1048 <h5><code>http2session.destroy([error][, code])</code><span><a class="mark" href="#http2sessiondest…
1053 …code>error</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Globa…
1055 …code>code</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#…
1056 If unspecified, and <code>error</code> is not undefined, the default is <code>INTERNAL_ERROR</code>,
1057 otherwise defaults to <code>NO_ERROR</code>.</li>
1059 <p>Immediately terminates the <code>Http2Session</code> and the associated <code>net.Socket</code> …
1060 <code>tls.TLSSocket</code>.</p>
1061 <p>Once destroyed, the <code>Http2Session</code> will emit the <code>'close'</code> event. If <code…
1062 is not undefined, an <code>'error'</code> event will be emitted immediately before the
1063 <code>'close'</code> event.</p>
1064 <p>If there are any remaining open <code>Http2Streams</code> associated with the
1065 <code>Http2Session</code>, those will also be destroyed.</p>
1066 <h5><code>http2session.destroyed</code><span><a class="mark" href="#http2sessiondestroyed" id="http…
1073 <p>Will be <code>true</code> if this <code>Http2Session</code> instance has been destroyed and must…
1074 longer be used, otherwise <code>false</code>.</p>
1075 <h5><code>http2session.encrypted</code><span><a class="mark" href="#http2sessionencrypted" id="http…
1082 <p>Value is <code>undefined</code> if the <code>Http2Session</code> session socket has not yet been
1083 connected, <code>true</code> if the <code>Http2Session</code> is connected with a <code>TLSSocket</…
1084 and <code>false</code> if the <code>Http2Session</code> is connected to any other kind of socket
1086 <h5><code>http2session.goaway([code[, lastStreamID[, opaqueData]]])</code><span><a class="mark" hre…
1091 …code>code</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#…
1092 …code>lastStreamID</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_str…
1093 …code>opaqueData</code> <a href="buffer.html#class-buffer" class="type"><Buffer></a> | <a href…
1094 instance containing additional data to be carried within the <code>GOAWAY</code> frame.</li>
1096 <p>Transmits a <code>GOAWAY</code> frame to the connected peer <em>without</em> shutting down the
1097 <code>Http2Session</code>.</p>
1098 <h5><code>http2session.localSettings</code><span><a class="mark" href="#http2sessionlocalsettings" …
1106 <code>Http2Session</code>. The local settings are local to <em>this</em> <code>Http2Session</code> …
1107 <h5><code>http2session.originSet</code><span><a class="mark" href="#http2sessionoriginset" id="http…
1114 <p>If the <code>Http2Session</code> is connected to a <code>TLSSocket</code>, the <code>originSet</…
1115 will return an <code>Array</code> of origins for which the <code>Http2Session</code> may be
1117 <p>The <code>originSet</code> property is only available when using a secure TLS connection.</p>
1118 <h5><code>http2session.pendingSettingsAck</code><span><a class="mark" href="#http2sessionpendingset…
1125 <p>Indicates whether the <code>Http2Session</code> is currently waiting for acknowledgment of
1126 a sent <code>SETTINGS</code> frame. Will be <code>true</code> after calling the
1127 <code>http2session.settings()</code> method. Will be <code>false</code> once all sent <code>SETTING…
1129 <h5><code>http2session.ping([payload, ]callback)</code><span><a class="mark" href="#http2sessionpin…
1135 …callback to the <code>callback</code> argument now throws <code>ERR_INVALID_ARG_TYPE</code> instea…
1142 <li><code>payload</code> <a href="buffer.html#class-buffer" class="type"><Buffer></a> | <a hre…
1143 <li><code>callback</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Referenc…
1146 <p>Sends a <code>PING</code> frame to the connected HTTP/2 peer. A <code>callback</code> function m…
1147 be provided. The method will return <code>true</code> if the <code>PING</code> was sent, <code>fals…
1150 <code>maxOutstandingPings</code> configuration option. The default maximum is 10.</p>
1151 <p>If provided, the <code>payload</code> must be a <code>Buffer</code>, <code>TypedArray</code>, or…
1152 containing 8 bytes of data that will be transmitted with the <code>PING</code> and
1155 be <code>null</code> if the <code>PING</code> was successfully acknowledged, a <code>duration</code…
1157 acknowledgment was received, and a <code>Buffer</code> containing the 8-byte <code>PING</code>
1159 <pre><code class="language-js">session.<span class="hljs-title function_">ping</span>(<span class="…
1164 });</code> <button class="copy-button">copy</button></pre>
1165 <p>If the <code>payload</code> argument is not specified, the default payload will be the
1166 64-bit timestamp (little endian) marking the start of the <code>PING</code> duration.</p>
1167 <h5><code>http2session.ref()</code><span><a class="mark" href="#http2sessionref" id="http2sessionre…
1171 <p>Calls <a href="net.html#socketref"><code>ref()</code></a> on this <code>Http2Session</code>
1172 instance's underlying <a href="net.html#class-netsocket"><code>net.Socket</code></a>.</p>
1173 <h5><code>http2session.remoteSettings</code><span><a class="mark" href="#http2sessionremotesettings…
1181 <code>Http2Session</code>. The remote settings are set by the <em>connected</em> HTTP/2 peer.</p>
1182 <h5><code>http2session.setLocalWindowSize(windowSize)</code><span><a class="mark" href="#http2sessi…
1187 <li><code>windowSize</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_s…
1190 The <code>windowSize</code> is the total window size to set, not
1192 <pre><code class="language-js"><span class="hljs-keyword">const</span> http2 = <span class="hljs-bu…
1200 });</code> <button class="copy-button">copy</button></pre>
1201 <h5><code>http2session.setTimeout(msecs, callback)</code><span><a class="mark" href="#http2sessions…
1207 …callback to the <code>callback</code> argument now throws <code>ERR_INVALID_ARG_TYPE</code> instea…
1214 <li><code>msecs</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_struct…
1215 <li><code>callback</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Referenc…
1218 the <code>Http2Session</code> after <code>msecs</code> milliseconds. The given <code>callback</code…
1219 registered as a listener on the <code>'timeout'</code> event.</p>
1220 <h5><code>http2session.socket</code><span><a class="mark" href="#http2sessionsocket" id="http2sessi…
1227 <p>Returns a <code>Proxy</code> object that acts as a <code>net.Socket</code> (or <code>tls.TLSSock…
1229 <p><code>destroy</code>, <code>emit</code>, <code>end</code>, <code>pause</code>, <code>read</code>…
1230 an error with code <code>ERR_HTTP2_NO_SOCKET_MANIPULATION</code>. See
1231 <a href="#http2session-and-sockets"><code>Http2Session</code> and Sockets</a> for more information.…
1232 <p><code>setTimeout</code> method will be called on this <code>Http2Session</code>.</p>
1234 <h5><code>http2session.state</code><span><a class="mark" href="#http2sessionstate" id="http2session…
1239 <code>Http2Session</code>.</p>
1243 <li><code>effectiveLocalWindowSize</code> <a href="https://developer.mozilla.org/en-US/docs/Web/Jav…
1244 flow control window size for the <code>Http2Session</code>.</li>
1245 <li><code>effectiveRecvDataLength</code> <a href="https://developer.mozilla.org/en-US/docs/Web/Java…
1246 that have been received since the last flow control <code>WINDOW_UPDATE</code>.</li>
1247 <li><code>nextStreamID</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data…
1248 next time a new <code>Http2Stream</code> is created by this <code>Http2Session</code>.</li>
1249 <li><code>localWindowSize</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/D…
1250 send without receiving a <code>WINDOW_UPDATE</code>.</li>
1251 …code>lastProcStreamID</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data…
1252 for which a <code>HEADERS</code> or <code>DATA</code> frame was most recently received.</li>
1253 …code>remoteWindowSize</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data…
1254 may send without receiving a <code>WINDOW_UPDATE</code>.</li>
1255 <li><code>outboundQueueSize</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript…
1256 outbound queue for this <code>Http2Session</code>.</li>
1257 <li><code>deflateDynamicTableSize</code> <a href="https://developer.mozilla.org/en-US/docs/Web/Java…
1259 <li><code>inflateDynamicTableSize</code> <a href="https://developer.mozilla.org/en-US/docs/Web/Java…
1264 <p>An object describing the current status of this <code>Http2Session</code>.</p>
1265 <h5><code>http2session.settings([settings][, callback])</code><span><a class="mark" href="#http2ses…
1271 …callback to the <code>callback</code> argument now throws <code>ERR_INVALID_ARG_TYPE</code> instea…
1278 <li><code>settings</code> <a href="http2.html#settings-object" class="type"><HTTP/2 Settings O…
1279 <li><code>callback</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Referenc…
1282 <li><code>err</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Glo…
1283 <li><code>settings</code> <a href="http2.html#settings-object" class="type"><HTTP/2 Settings O…
1284 <li><code>duration</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_str…
1288 <p>Updates the current local settings for this <code>Http2Session</code> and sends a new
1289 <code>SETTINGS</code> frame to the connected HTTP/2 peer.</p>
1290 <p>Once called, the <code>http2session.pendingSettingsAck</code> property will be <code>true</code>
1293 <p>The new settings will not become effective until the <code>SETTINGS</code> acknowledgment
1294 is received and the <code>'localSettings'</code> event is emitted. It is possible to send
1295 multiple <code>SETTINGS</code> frames while acknowledgment is still pending.</p>
1296 <h5><code>http2session.type</code><span><a class="mark" href="#http2sessiontype" id="http2sessionty…
1303 <p>The <code>http2session.type</code> will be equal to
1304 <code>http2.constants.NGHTTP2_SESSION_SERVER</code> if this <code>Http2Session</code> instance is a
1305 server, and <code>http2.constants.NGHTTP2_SESSION_CLIENT</code> if the instance is a
1307 <h5><code>http2session.unref()</code><span><a class="mark" href="#http2sessionunref" id="http2sessi…
1311 <p>Calls <a href="net.html#socketunref"><code>unref()</code></a> on this <code>Http2Session</code>
1312 instance's underlying <a href="net.html#class-netsocket"><code>net.Socket</code></a>.</p>
1313 <h4>Class: <code>ServerHttp2Session</code><span><a class="mark" href="#class-serverhttp2session" id…
1320 <h5><code>serverhttp2session.altsvc(alt, originOrStream)</code><span><a class="mark" href="#serverh…
1325 <li><code>alt</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structur…
1327 <li><code>originOrStream</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Da…
1328 the origin (or an <code>Object</code> with an <code>origin</code> property) or the numeric
1329 identifier of an active <code>Http2Stream</code> as given by the <code>http2stream.id</code>
1332 <p>Submits an <code>ALTSVC</code> frame (as defined by <a href="https://tools.ietf.org/html/rfc7838…
1333 <pre><code class="language-js"><span class="hljs-keyword">const</span> http2 = <span class="hljs-bu…
1344 });</code> <button class="copy-button">copy</button></pre>
1345 <p>Sending an <code>ALTSVC</code> frame with a specific stream ID indicates that the alternate
1346 service is associated with the origin of the given <code>Http2Stream</code>.</p>
1347 <p>The <code>alt</code> and origin string <em>must</em> contain only ASCII bytes and are
1348 strictly interpreted as a sequence of ASCII bytes. The special value <code>'clear'</code>
1351 <p>When a string is passed for the <code>originOrStream</code> argument, it will be parsed as
1353 HTTP URL <code>'https://example.org/foo/bar'</code> is the ASCII string
1354 <code>'https://example.org'</code>. An error will be thrown if either the given string
1356 <p>A <code>URL</code> object, or any object with an <code>origin</code> property, may be passed as
1357 <code>originOrStream</code>, in which case the value of the <code>origin</code> property will be
1358 used. The value of the <code>origin</code> property <em>must</em> be a properly serialized
1361 <p>The format of the <code>alt</code> parameter is strictly defined by <a href="https://tools.ietf.…
1364 <p>For example, the value <code>'h2="example.org:81"'</code> indicates that the HTTP/2
1365 protocol is available on the host <code>'example.org'</code> on TCP/IP port 81. The
1366 host and port <em>must</em> be contained within the quote (<code>"</code>) characters.</p>
1367 …Multiple alternatives may be specified, for instance: <code>'h2="example.org:81", h2=":82"'</code>…
1368 <p>The protocol identifier (<code>'h2'</code> in the examples) may be any valid
1372 <h5><code>serverhttp2session.origin(...origins)</code><span><a class="mark" href="#serverhttp2sessi…
1377 <li><code>origins</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_stru…
1380 <p>Submits an <code>ORIGIN</code> frame (as defined by <a href="https://tools.ietf.org/html/rfc8336…
1383 <pre><code class="language-js"><span class="hljs-keyword">const</span> http2 = <span class="hljs-bu…
1392 });</code> <button class="copy-button">copy</button></pre>
1393 <p>When a string is passed as an <code>origin</code>, it will be parsed as a URL and the
1395 <code>'https://example.org/foo/bar'</code> is the ASCII string
1396 <code>'https://example.org'</code>. An error will be thrown if either the given string
1398 <p>A <code>URL</code> object, or any object with an <code>origin</code> property, may be passed as
1399 an <code>origin</code>, in which case the value of the <code>origin</code> property will be
1400 used. The value of the <code>origin</code> property <em>must</em> be a properly serialized
1402 <p>Alternatively, the <code>origins</code> option may be used when creating a new HTTP/2
1403 server using the <code>http2.createSecureServer()</code> method:</p>
1404 <pre><code class="language-js"><span class="hljs-keyword">const</span> http2 = <span class="hljs-bu…
1411 });</code> <button class="copy-button">copy</button></pre>
1412 <h4>Class: <code>ClientHttp2Session</code><span><a class="mark" href="#class-clienthttp2session" id…
1419 <h5>Event: <code>'altsvc'</code><span><a class="mark" href="#event-altsvc" id="event-altsvc">#</a><…
1424 <li><code>alt</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structur…
1425 <li><code>origin</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_struc…
1426 <li><code>streamId</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_str…
1428 <p>The <code>'altsvc'</code> event is emitted whenever an <code>ALTSVC</code> frame is received by
1429 the client. The event is emitted with the <code>ALTSVC</code> value, origin, and stream
1430 ID. If no <code>origin</code> is provided in the <code>ALTSVC</code> frame, <code>origin</code> will
1432 <pre><code class="language-js"><span class="hljs-keyword">const</span> http2 = <span class="hljs-bu…
1439 });</code> <button class="copy-button">copy</button></pre>
1440 <h5>Event: <code>'origin'</code><span><a class="mark" href="#event-origin" id="event-origin">#</a><…
1445 <li><code>origins</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_stru…
1447 <p>The <code>'origin'</code> event is emitted whenever an <code>ORIGIN</code> frame is received by
1448 the client. The event is emitted with an array of <code>origin</code> strings. The
1449 <code>http2session.originSet</code> will be updated to include the received
1451 <pre><code class="language-js"><span class="hljs-keyword">const</span> http2 = <span class="hljs-bu…
1457 });</code> <button class="copy-button">copy</button></pre>
1458 <p>The <code>'origin'</code> event is only emitted when using a secure TLS connection.</p>
1459 <h5><code>clienthttp2session.request(headers[, options])</code><span><a class="mark" href="#clienth…
1465 <p><code>headers</code> <a href="http2.html#headers-object" class="type"><HTTP/2 Headers Objec…
1468 <p><code>options</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…
1470 …code>endStream</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_struct…
1471 be closed initially, such as when sending a <code>GET</code> request that should not
1473 …code>exclusive</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_struct…
1476 <strong>Default:</strong> <code>false</code>.</li>
1477 <li><code>parent</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_struc…
1479 <li><code>weight</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_struc…
1480 to other streams with the same <code>parent</code>. The value is a number between <code>1</code>
1481 and <code>256</code> (inclusive).</li>
1482 …code>waitForTrailers</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_…
1483 <code>'wantTrailers'</code> event after the final <code>DATA</code> frame has been sent.</li>
1484 <li><code>signal</code> <a href="globals.html#class-abortsignal" class="type"><AbortSignal></a…
1492 <p>For HTTP/2 Client <code>Http2Session</code> instances only, the <code>http2session.request()</co…
1493 creates and returns an <code>Http2Stream</code> instance that can be used to send an
1495 <p>When a <code>ClientHttp2Session</code> is first created, the socket may not yet be
1496 connected. if <code>clienthttp2session.request()</code> is called during this time, the
1498 If the <code>session</code> is closed before the actual request be executed, an
1499 <code>ERR_HTTP2_GOAWAY_SESSION</code> is thrown.</p>
1500 <p>This method is only available if <code>http2session.type</code> is equal to
1501 <code>http2.constants.NGHTTP2_SESSION_CLIENT</code>.</p>
1502 <pre><code class="language-js"><span class="hljs-keyword">const</span> http2 = <span class="hljs-bu…
1514 });</code> <button class="copy-button">copy</button></pre>
1515 <p>When the <code>options.waitForTrailers</code> option is set, the <code>'wantTrailers'</code> eve…
1517 The <code>http2stream.sendTrailers()</code> method can then be called to send trailing
1519 <p>When <code>options.waitForTrailers</code> is set, the <code>Http2Stream</code> will not automati…
1520 close when the final <code>DATA</code> frame is transmitted. User code must call either
1521 <code>http2stream.sendTrailers()</code> or <code>http2stream.close()</code> to close the
1522 <code>Http2Stream</code>.</p>
1523 <p>When <code>options.signal</code> is set with an <code>AbortSignal</code> and then <code>abort</c…
1524 corresponding <code>AbortController</code> is called, the request will emit an <code>'error'</code>
1525 event with an <code>AbortError</code> error.</p>
1526 <p>The <code>:method</code> and <code>:path</code> pseudo-headers are not specified within <code>he…
1529 <li><code>:method</code> = <code>'GET'</code></li>
1530 <li><code>:path</code> = <code>/</code></li>
1532 <h4>Class: <code>Http2Stream</code><span><a class="mark" href="#class-http2stream" id="class-http2s…
1539 <p>Each instance of the <code>Http2Stream</code> class represents a bidirectional HTTP/2
1540 communications stream over an <code>Http2Session</code> instance. Any single <code>Http2Session</co…
1541 may have up to 2<sup>31</sup>-1 <code>Http2Stream</code> instances over its lifetime.</p>
1542 <p>User code will not construct <code>Http2Stream</code> instances directly. Rather, these
1543 are created, managed, and provided to user code through the <code>Http2Session</code>
1544 instance. On the server, <code>Http2Stream</code> instances are created either in response
1545 to an incoming HTTP request (and handed off to user code via the <code>'stream'</code>
1546 event), or in response to a call to the <code>http2stream.pushStream()</code> method.
1547 On the client, <code>Http2Stream</code> instances are created and returned when either the
1548 <code>http2session.request()</code> method is called, or in response to an incoming
1549 <code>'push'</code> event.</p>
1550 <p>The <code>Http2Stream</code> class is a base for the <a href="#class-serverhttp2stream"><code>Se…
1551 <a href="#class-clienthttp2stream"><code>ClientHttp2Stream</code></a> classes, each of which is use…
1553 <p>All <code>Http2Stream</code> instances are <a href="stream.html#class-streamduplex"><code>Duplex…
1554 <code>Duplex</code> is used to send data to the connected peer, while the <code>Readable</code> side
1556 <p>The default text character encoding for an <code>Http2Stream</code> is UTF-8. When using an
1557 <code>Http2Stream</code> to send text, use the <code>'content-type'</code> header to set the charac…
1559 <pre><code class="language-js">stream.<span class="hljs-title function_">respond</span>({
1562 });</code> <button class="copy-button">copy</button></pre>
1563 <h5><code>Http2Stream</code> Lifecycle<span><a class="mark" href="#http2stream-lifecycle" id="http2…
1565 …server side, instances of <a href="#class-serverhttp2stream"><code>ServerHttp2Stream</code></a> ar…
1568 <li>A new HTTP/2 <code>HEADERS</code> frame with a previously unused stream ID is received;</li>
1569 <li>The <code>http2stream.pushStream()</code> method is called.</li>
1571 …client side, instances of <a href="#class-clienthttp2stream"><code>ClientHttp2Stream</code></a> ar…
1572 <code>http2session.request()</code> method is called.</p>
1573 <p>On the client, the <code>Http2Stream</code> instance returned by <code>http2session.request()</c…
1574 may not be immediately ready for use if the parent <code>Http2Session</code> has not yet
1575 been fully established. In such cases, operations called on the <code>Http2Stream</code>
1576 will be buffered until the <code>'ready'</code> event is emitted. User code should rarely,
1577 if ever, need to handle the <code>'ready'</code> event directly. The ready status of an
1578 <code>Http2Stream</code> can be determined by checking the value of <code>http2stream.id</code>. If
1579 the value is <code>undefined</code>, the stream is not yet ready for use.</p>
1581 <p>All <a href="#class-http2stream"><code>Http2Stream</code></a> instances are destroyed either whe…
1583 <li>An <code>RST_STREAM</code> frame for the stream is received by the connected peer,
1585 <li>The <code>http2stream.close()</code> method is called, and (for client streams only)
1587 <li>The <code>http2stream.destroy()</code> or <code>http2session.destroy()</code> methods are calle…
1589 <p>When an <code>Http2Stream</code> instance is destroyed, an attempt will be made to send an
1590 <code>RST_STREAM</code> frame to the connected peer.</p>
1591 <p>When the <code>Http2Stream</code> instance is destroyed, the <code>'close'</code> event will
1592 be emitted. Because <code>Http2Stream</code> is an instance of <code>stream.Duplex</code>, the
1593 <code>'end'</code> event will also be emitted if the stream data is currently flowing.
1594 The <code>'error'</code> event may also be emitted if <code>http2stream.destroy()</code> was called
1595 with an <code>Error</code> passed as the first argument.</p>
1596 <p>After the <code>Http2Stream</code> has been destroyed, the <code>http2stream.destroyed</code>
1597 property will be <code>true</code> and the <code>http2stream.rstCode</code> property will specify t…
1598 <code>RST_STREAM</code> error code. The <code>Http2Stream</code> instance is no longer usable once
1600 <h5>Event: <code>'aborted'</code><span><a class="mark" href="#event-aborted" id="event-aborted">#</…
1604 <p>The <code>'aborted'</code> event is emitted whenever a <code>Http2Stream</code> instance is
1607 <p>The <code>'aborted'</code> event will only be emitted if the <code>Http2Stream</code> writable s…
1609 <h5>Event: <code>'close'</code><span><a class="mark" href="#event-close_1" id="event-close_1">#</a>…
1613 <p>The <code>'close'</code> event is emitted when the <code>Http2Stream</code> is destroyed. Once
1614 this event is emitted, the <code>Http2Stream</code> instance is no longer usable.</p>
1615 <p>The HTTP/2 error code used when closing the stream can be retrieved using
1616 the <code>http2stream.rstCode</code> property. If the code is any value other than
1617 <code>NGHTTP2_NO_ERROR</code> (<code>0</code>), an <code>'error'</code> event will have also been e…
1618 <h5>Event: <code>'error'</code><span><a class="mark" href="#event-error_1" id="event-error_1">#</a>…
1623 <li><code>error</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/G…
1625 <p>The <code>'error'</code> event is emitted when an error occurs during the processing of
1626 an <code>Http2Stream</code>.</p>
1627 <h5>Event: <code>'frameError'</code><span><a class="mark" href="#event-frameerror_1" id="event-fram…
1632 <li><code>type</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structu…
1633 …code>code</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#…
1634 …code>id</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Nu…
1637 <p>The <code>'frameError'</code> event is emitted when an error occurs while attempting to
1640 error code. The <code>Http2Stream</code> instance will be destroyed immediately after the
1641 <code>'frameError'</code> event is emitted.</p>
1642 <h5>Event: <code>'ready'</code><span><a class="mark" href="#event-ready" id="event-ready">#</a></sp…
1646 <p>The <code>'ready'</code> event is emitted when the <code>Http2Stream</code> has been opened, has
1647 been assigned an <code>id</code>, and can be used. The listener does not expect any
1649 <h5>Event: <code>'timeout'</code><span><a class="mark" href="#event-timeout_1" id="event-timeout_1"…
1653 <p>The <code>'timeout'</code> event is emitted after no activity is received for this
1654 <code>Http2Stream</code> within the number of milliseconds set using
1655 <code>http2stream.setTimeout()</code>.
1657 <h5>Event: <code>'trailers'</code><span><a class="mark" href="#event-trailers" id="event-trailers">…
1662 <li><code>headers</code> <a href="http2.html#headers-object" class="type"><HTTP/2 Headers Obje…
1663 <li><code>flags</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_struct…
1665 <p>The <code>'trailers'</code> event is emitted when a block of headers associated with
1668 <p>This event might not be emitted if <code>http2stream.end()</code> is called
1671 <pre><code class="language-js">stream.<span class="hljs-title function_">on</span>(<span class="hlj…
1673 });</code> <button class="copy-button">copy</button></pre>
1674 <h5>Event: <code>'wantTrailers'</code><span><a class="mark" href="#event-wanttrailers" id="event-wa…
1678 <p>The <code>'wantTrailers'</code> event is emitted when the <code>Http2Stream</code> has queued the
1679 final <code>DATA</code> frame to be sent on a frame and the <code>Http2Stream</code> is ready to se…
1680 trailing headers. When initiating a request or response, the <code>waitForTrailers</code>
1682 <h5><code>http2stream.aborted</code><span><a class="mark" href="#http2streamaborted" id="http2strea…
1689 <p>Set to <code>true</code> if the <code>Http2Stream</code> instance was aborted abnormally. When s…
1690 the <code>'aborted'</code> event will have been emitted.</p>
1691 <h5><code>http2stream.bufferSize</code><span><a class="mark" href="#http2streambuffersize" id="http…
1699 See <a href="net.html#socketbuffersize"><code>net.Socket.bufferSize</code></a> for details.</p>
1700 <h5><code>http2stream.close(code[, callback])</code><span><a class="mark" href="#http2streamcloseco…
1706 …callback to the <code>callback</code> argument now throws <code>ERR_INVALID_ARG_TYPE</code> instea…
1713 …code>code</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#…
1714 <strong>Default:</strong> <code>http2.constants.NGHTTP2_NO_ERROR</code> (<code>0x00</code>).</li>
1715 <li><code>callback</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Referenc…
1716 <code>'close'</code> event.</li>
1718 <p>Closes the <code>Http2Stream</code> instance by sending an <code>RST_STREAM</code> frame to the
1720 <h5><code>http2stream.closed</code><span><a class="mark" href="#http2streamclosed" id="http2streamc…
1727 <p>Set to <code>true</code> if the <code>Http2Stream</code> instance has been closed.</p>
1728 <h5><code>http2stream.destroyed</code><span><a class="mark" href="#http2streamdestroyed" id="http2s…
1735 <p>Set to <code>true</code> if the <code>Http2Stream</code> instance has been destroyed and is no l…
1737 <h5><code>http2stream.endAfterHeaders</code><span><a class="mark" href="#http2streamendafterheaders…
1744 <p>Set to <code>true</code> if the <code>END_STREAM</code> flag was set in the request or response
1746 and the readable side of the <code>Http2Stream</code> will be closed.</p>
1747 <h5><code>http2stream.id</code><span><a class="mark" href="#http2streamid" id="http2streamid">#</a>…
1754 <p>The numeric stream identifier of this <code>Http2Stream</code> instance. Set to <code>undefined<…
1756 <h5><code>http2stream.pending</code><span><a class="mark" href="#http2streampending" id="http2strea…
1763 <p>Set to <code>true</code> if the <code>Http2Stream</code> instance has not yet been assigned a
1765 <h5><code>http2stream.priority(options)</code><span><a class="mark" href="#http2streampriorityoptio…
1770 <li><code>options</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference…
1772 …code>exclusive</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_struct…
1775 <code>false</code>.</li>
1776 <li><code>parent</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_struc…
1778 <li><code>weight</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_struc…
1779 to other streams with the same <code>parent</code>. The value is a number between <code>1</code>
1780 and <code>256</code> (inclusive).</li>
1781 …code>silent</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structure…
1782 sending a <code>PRIORITY</code> frame to the connected peer.</li>
1786 <p>Updates the priority for this <code>Http2Stream</code> instance.</p>
1787 <h5><code>http2stream.rstCode</code><span><a class="mark" href="#http2streamrstcode" id="http2strea…
1794 …Set to the <code>RST_STREAM</code> <a href="#error-codes-for-rst_stream-and-goaway">error code</a>…
1795 destroyed after either receiving an <code>RST_STREAM</code> frame from the connected peer,
1796 calling <code>http2stream.close()</code>, or <code>http2stream.destroy()</code>. Will be
1797 <code>undefined</code> if the <code>Http2Stream</code> has not been closed.</p>
1798 <h5><code>http2stream.sentHeaders</code><span><a class="mark" href="#http2streamsentheaders" id="ht…
1805 <p>An object containing the outbound headers sent for this <code>Http2Stream</code>.</p>
1806 <h5><code>http2stream.sentInfoHeaders</code><span><a class="mark" href="#http2streamsentinfoheaders…
1814 sent for this <code>Http2Stream</code>.</p>
1815 <h5><code>http2stream.sentTrailers</code><span><a class="mark" href="#http2streamsenttrailers" id="…
1822 <p>An object containing the outbound trailers sent for this <code>HttpStream</code>.</p>
1823 <h5><code>http2stream.session</code><span><a class="mark" href="#http2streamsession" id="http2strea…
1830 <p>A reference to the <code>Http2Session</code> instance that owns this <code>Http2Stream</code>. T…
1831 value will be <code>undefined</code> after the <code>Http2Stream</code> instance is destroyed.</p>
1832 <h5><code>http2stream.setTimeout(msecs, callback)</code><span><a class="mark" href="#http2streamset…
1838 …callback to the <code>callback</code> argument now throws <code>ERR_INVALID_ARG_TYPE</code> instea…
1845 <li><code>msecs</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_struct…
1846 <li><code>callback</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Referenc…
1848 <pre><code class="language-js"><span class="hljs-keyword">const</span> http2 = <span class="hljs-bu…
1854 …_">close</span>(<span class="hljs-title class_">NGHTTP2</span>_CANCEL));</code> <button class="cop…
1855 <h5><code>http2stream.state</code><span><a class="mark" href="#http2streamstate" id="http2streamsta…
1860 <code>Http2Stream</code>.</p>
1864 <li><code>localWindowSize</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/D…
1865 for this <code>Http2Stream</code> without receiving a <code>WINDOW_UPDATE</code>.</li>
1866 <li><code>state</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_struct…
1867 <code>Http2Stream</code> as determined by <code>nghttp2</code>.</li>
1868 …code>localClose</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_struc…
1869 …code>remoteClose</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_stru…
1871 …code>sumDependencyWeight</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/D…
1872 instances that depend on this <code>Http2Stream</code> as specified using
1873 <code>PRIORITY</code> frames.</li>
1874 …code>weight</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structure…
1878 <p>A current state of this <code>Http2Stream</code>.</p>
1879 <h5><code>http2stream.sendTrailers(headers)</code><span><a class="mark" href="#http2streamsendtrail…
1884 <li><code>headers</code> <a href="http2.html#headers-object" class="type"><HTTP/2 Headers Obje…
1886 <p>Sends a trailing <code>HEADERS</code> frame to the connected HTTP/2 peer. This method
1887 will cause the <code>Http2Stream</code> to be immediately closed and must only be
1888 called after the <code>'wantTrailers'</code> event has been emitted. When sending a
1889 request or sending a response, the <code>options.waitForTrailers</code> option must be set
1890 in order to keep the <code>Http2Stream</code> open after the final <code>DATA</code> frame so that
1892 <pre><code class="language-js"><span class="hljs-keyword">const</span> http2 = <span class="hljs-bu…
1900 });</code> <button class="copy-button">copy</button></pre>
1902 fields (e.g. <code>':method'</code>, <code>':path'</code>, etc).</p>
1903 <h4>Class: <code>ClientHttp2Stream</code><span><a class="mark" href="#class-clienthttp2stream" id="…
1910 <p>The <code>ClientHttp2Stream</code> class is an extension of <code>Http2Stream</code> that is
1911 used exclusively on HTTP/2 Clients. <code>Http2Stream</code> instances on the client
1912 provide events such as <code>'response'</code> and <code>'push'</code> that are only relevant on
1914 <h5>Event: <code>'continue'</code><span><a class="mark" href="#event-continue" id="event-continue">…
1918 <p>Emitted when the server sends a <code>100 Continue</code> status, usually because
1919 the request contained <code>Expect: 100-continue</code>. This is an instruction that
1921 <h5>Event: <code>'headers'</code><span><a class="mark" href="#event-headers" id="event-headers">#</…
1926 <li><code>headers</code> <a href="http2.html#headers-object" class="type"><HTTP/2 Headers Obje…
1927 <li><code>flags</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_struct…
1929 <p>The <code>'headers'</code> event is emitted when an additional block of headers is received
1930 for a stream, such as when a block of <code>1xx</code> informational headers is received.
1933 <pre><code class="language-js">stream.<span class="hljs-title function_">on</span>(<span class="hlj…
1935 });</code> <button class="copy-button">copy</button></pre>
1936 <h5>Event: <code>'push'</code><span><a class="mark" href="#event-push" id="event-push">#</a></span>…
1941 <li><code>headers</code> <a href="http2.html#headers-object" class="type"><HTTP/2 Headers Obje…
1942 <li><code>flags</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_struct…
1944 <p>The <code>'push'</code> event is emitted when response headers for a Server Push stream
1947 <pre><code class="language-js">stream.<span class="hljs-title function_">on</span>(<span class="hlj…
1949 });</code> <button class="copy-button">copy</button></pre>
1950 <h5>Event: <code>'response'</code><span><a class="mark" href="#event-response" id="event-response">…
1955 <li><code>headers</code> <a href="http2.html#headers-object" class="type"><HTTP/2 Headers Obje…
1956 <li><code>flags</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_struct…
1958 <p>The <code>'response'</code> event is emitted when a response <code>HEADERS</code> frame has been
1960 invoked with two arguments: an <code>Object</code> containing the received
1962 <pre><code class="language-js"><span class="hljs-keyword">const</span> http2 = <span class="hljs-bu…
1967 });</code> <button class="copy-button">copy</button></pre>
1968 <h4>Class: <code>ServerHttp2Stream</code><span><a class="mark" href="#class-serverhttp2stream" id="…
1975 <p>The <code>ServerHttp2Stream</code> class is an extension of <a href="#class-http2stream"><code>H…
1976 used exclusively on HTTP/2 Servers. <code>Http2Stream</code> instances on the server
1977 provide additional methods such as <code>http2stream.pushStream()</code> and
1978 <code>http2stream.respond()</code> that are only relevant on the server.</p>
1979 <h5><code>http2stream.additionalHeaders(headers)</code><span><a class="mark" href="#http2streamaddi…
1984 <li><code>headers</code> <a href="http2.html#headers-object" class="type"><HTTP/2 Headers Obje…
1986 <p>Sends an additional informational <code>HEADERS</code> frame to the connected HTTP/2 peer.</p>
1987 <h5><code>http2stream.headersSent</code><span><a class="mark" href="#http2streamheaderssent" id="ht…
1995 <h5><code>http2stream.pushAllowed</code><span><a class="mark" href="#http2streampushallowed" id="ht…
2002 <p>Read-only property mapped to the <code>SETTINGS_ENABLE_PUSH</code> flag of the remote
2003 client's most recent <code>SETTINGS</code> frame. Will be <code>true</code> if the remote peer
2004 accepts push streams, <code>false</code> otherwise. Settings are the same for every
2005 <code>Http2Stream</code> in the same <code>Http2Session</code>.</p>
2006 <h5><code>http2stream.pushStream(headers[, options], callback)</code><span><a class="mark" href="#h…
2012 …callback to the <code>callback</code> argument now throws <code>ERR_INVALID_ARG_TYPE</code> instea…
2019 <li><code>headers</code> <a href="http2.html#headers-object" class="type"><HTTP/2 Headers Obje…
2020 <li><code>options</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference…
2022 …code>exclusive</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_struct…
2025 <strong>Default:</strong> <code>false</code>.</li>
2026 <li><code>parent</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_struc…
2030 <li><code>callback</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Referenc…
2033 <li><code>err</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Glo…
2034 …li><code>pushStream</code> <a href="http2.html#class-serverhttp2stream" class="type"><ServerH…
2035 <li><code>headers</code> <a href="http2.html#headers-object" class="type"><HTTP/2 Headers Obje…
2040 <p>Initiates a push stream. The callback is invoked with the new <code>Http2Stream</code>
2042 <code>Error</code> passed as the first argument.</p>
2043 <pre><code class="language-js"><span class="hljs-keyword">const</span> http2 = <span class="hljs-bu…
2053 });</code> <button class="copy-button">copy</button></pre>
2054 <p>Setting the weight of a push stream is not allowed in the <code>HEADERS</code> frame. Pass
2055 a <code>weight</code> value to <code>http2stream.priority</code> with the <code>silent</code> optio…
2056 <code>true</code> to enable server-side bandwidth balancing between concurrent streams.</p>
2057 <p>Calling <code>http2stream.pushStream()</code> from within a pushed stream is not permitted
2059 <h5><code>http2stream.respond([headers[, options]])</code><span><a class="mark" href="#http2streamr…
2072 <li><code>headers</code> <a href="http2.html#headers-object" class="type"><HTTP/2 Headers Obje…
2073 <li><code>options</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference…
2075 …code>endStream</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_struct…
2077 …code>waitForTrailers</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_…
2078 <code>'wantTrailers'</code> event after the final <code>DATA</code> frame has been sent.</li>
2082 <pre><code class="language-js"><span class="hljs-keyword">const</span> http2 = <span class="hljs-bu…
2087 });</code> <button class="copy-button">copy</button></pre>
2088 <p>Initiates a response. When the <code>options.waitForTrailers</code> option is set, the
2089 <code>'wantTrailers'</code> event will be emitted immediately after queuing the last chunk
2090 of payload data to be sent. The <code>http2stream.sendTrailers()</code> method can then be
2092 <p>When <code>options.waitForTrailers</code> is set, the <code>Http2Stream</code> will not automati…
2093 close when the final <code>DATA</code> frame is transmitted. User code must call either
2094 <code>http2stream.sendTrailers()</code> or <code>http2stream.close()</code> to close the
2095 <code>Http2Stream</code>.</p>
2096 <pre><code class="language-js"><span class="hljs-keyword">const</span> http2 = <span class="hljs-bu…
2104 });</code> <button class="copy-button">copy</button></pre>
2105 <h5><code>http2stream.respondWithFD(fd[, headers[, options]])</code><span><a class="mark" href="#ht…
2113 <td><p>The <code>fd</code> option may now be a <code>FileHandle</code>.</p></td></tr>
2122 <li><code>fd</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structure…
2123 <li><code>headers</code> <a href="http2.html#headers-object" class="type"><HTTP/2 Headers Obje…
2124 <li><code>options</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference…
2126 <li><code>statCheck</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Referen…
2127 …code>waitForTrailers</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_…
2128 <code>'wantTrailers'</code> event after the final <code>DATA</code> frame has been sent.</li>
2129 <li><code>offset</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_struc…
2130 <li><code>length</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_struc…
2136 attempting to read data using the file descriptor, the <code>Http2Stream</code> will be
2137 closed using an <code>RST_STREAM</code> frame using the standard <code>INTERNAL_ERROR</code> code.<…
2138 <p>When used, the <code>Http2Stream</code> object's <code>Duplex</code> interface will be closed
2140 <pre><code class="language-js"><span class="hljs-keyword">const</span> http2 = <span class="hljs-bu…
2155 });</code> <button class="copy-button">copy</button></pre>
2156 <p>The optional <code>options.statCheck</code> function may be specified to give user code
2157 an opportunity to set additional content headers based on the <code>fs.Stat</code> details
2158 of the given fd. If the <code>statCheck</code> function is provided, the
2159 <code>http2stream.respondWithFD()</code> method will perform an <code>fs.fstat()</code> call to
2161 <p>The <code>offset</code> and <code>length</code> options may be used to limit the response to a
2164 <p>The file descriptor or <code>FileHandle</code> is not closed when the stream is closed,
2169 <p>When the <code>options.waitForTrailers</code> option is set, the <code>'wantTrailers'</code> eve…
2171 sent. The <code>http2stream.sendTrailers()</code> method can then be used to sent trailing
2173 <p>When <code>options.waitForTrailers</code> is set, the <code>Http2Stream</code> will not automati…
2174 close when the final <code>DATA</code> frame is transmitted. User code <em>must</em> call either
2175 <code>http2stream.sendTrailers()</code> or <code>http2stream.close()</code> to close the
2176 <code>Http2Stream</code>.</p>
2177 <pre><code class="language-js"><span class="hljs-keyword">const</span> http2 = <span class="hljs-bu…
2196 });</code> <button class="copy-button">copy</button></pre>
2197 <h5><code>http2stream.respondWithFile(path[, headers[, options]])</code><span><a class="mark" href=…
2212 <li><code>path</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structu…
2213 <li><code>headers</code> <a href="http2.html#headers-object" class="type"><HTTP/2 Headers Obje…
2214 <li><code>options</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference…
2216 <li><code>statCheck</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Referen…
2217 <li><code>onError</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference…
2219 …code>waitForTrailers</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_…
2220 <code>'wantTrailers'</code> event after the final <code>DATA</code> frame has been sent.</li>
2221 <li><code>offset</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_struc…
2222 <li><code>length</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_struc…
2226 <p>Sends a regular file as the response. The <code>path</code> must specify a regular file
2227 or an <code>'error'</code> event will be emitted on the <code>Http2Stream</code> object.</p>
2228 <p>When used, the <code>Http2Stream</code> object's <code>Duplex</code> interface will be closed
2230 <p>The optional <code>options.statCheck</code> function may be specified to give user code
2231 an opportunity to set additional content headers based on the <code>fs.Stat</code> details
2233 <p>If an error occurs while attempting to read the file data, the <code>Http2Stream</code>
2234 will be closed using an <code>RST_STREAM</code> frame using the standard <code>INTERNAL_ERROR</code>
2235 code. If the <code>onError</code> callback is defined, then it will be called. Otherwise
2238 <pre><code class="language-js"><span class="hljs-keyword">const</span> http2 = <span class="hljs-bu…
2249 …<span class="hljs-keyword">if</span> (err.<span class="hljs-property">code</span> === <span class=…
2264 });</code> <button class="copy-button">copy</button></pre>
2265 <p>The <code>options.statCheck</code> function may also be used to cancel the send operation
2266 by returning <code>false</code>. For instance, a conditional request may check the stat
2268 <code>304</code> response:</p>
2269 <pre><code class="language-js"><span class="hljs-keyword">const</span> http2 = <span class="hljs-bu…
2280 });</code> <button class="copy-button">copy</button></pre>
2281 <p>The <code>content-length</code> header field will be automatically set.</p>
2282 <p>The <code>offset</code> and <code>length</code> options may be used to limit the response to a
2285 <p>The <code>options.onError</code> function may also be used to handle all the errors
2288 <p>When the <code>options.waitForTrailers</code> option is set, the <code>'wantTrailers'</code> eve…
2290 sent. The <code>http2stream.sendTrailers()</code> method can then be used to sent trailing
2292 <p>When <code>options.waitForTrailers</code> is set, the <code>Http2Stream</code> will not automati…
2293 close when the final <code>DATA</code> frame is transmitted. User code must call either
2294 <code>http2stream.sendTrailers()</code> or <code>http2stream.close()</code> to close the
2295 <code>Http2Stream</code>.</p>
2296 <pre><code class="language-js"><span class="hljs-keyword">const</span> http2 = <span class="hljs-bu…
2305 });</code> <button class="copy-button">copy</button></pre>
2306 <h4>Class: <code>Http2Server</code><span><a class="mark" href="#class-http2server" id="class-http2s…
2313 <p>Instances of <code>Http2Server</code> are created using the <code>http2.createServer()</code>
2314 function. The <code>Http2Server</code> class is not exported directly by the
2315 <code>node:http2</code> module.</p>
2316 <h5>Event: <code>'checkContinue'</code><span><a class="mark" href="#event-checkcontinue" id="event-…
2321 <li><code>request</code> <a href="http2.html#class-http2http2serverrequest" class="type"><http…
2322 <li><code>response</code> <a href="http2.html#class-http2http2serverresponse" class="type"><ht…
2324 …quest"><code>'request'</code></a> listener is registered or <a href="#http2createserveroptions-onr…
2325 supplied a callback function, the <code>'checkContinue'</code> event is emitted each time
2326 a request with an HTTP <code>Expect: 100-continue</code> is received. If this event is
2328 <code>100 Continue</code> as appropriate.</p>
2329 …s event involves calling <a href="#responsewritecontinue"><code>response.writeContinue()</code></a…
2333 <p>When this event is emitted and handled, the <a href="#event-request"><code>'request'</code></a> …
2335 <h5>Event: <code>'connection'</code><span><a class="mark" href="#event-connection" id="event-connec…
2340 <li><code>socket</code> <a href="stream.html#class-streamduplex" class="type"><stream.Duplex><…
2342 <p>This event is emitted when a new TCP stream is established. <code>socket</code> is
2343 typically an object of type <a href="net.html#class-netsocket"><code>net.Socket</code></a>. Usually…
2346 into the HTTP server. In that case, any <a href="stream.html#class-streamduplex"><code>Duplex</code…
2347 <h5>Event: <code>'request'</code><span><a class="mark" href="#event-request" id="event-request">#</…
2352 <li><code>request</code> <a href="http2.html#class-http2http2serverrequest" class="type"><http…
2353 <li><code>response</code> <a href="http2.html#class-http2http2serverresponse" class="type"><ht…
2357 <h5>Event: <code>'session'</code><span><a class="mark" href="#event-session" id="event-session">#</…
2362 <li><code>session</code> <a href="http2.html#class-serverhttp2session" class="type"><ServerHtt…
2364 <p>The <code>'session'</code> event is emitted when a new <code>Http2Session</code> is created by t…
2365 <code>Http2Server</code>.</p>
2366 <h5>Event: <code>'sessionError'</code><span><a class="mark" href="#event-sessionerror" id="event-se…
2371 <li><code>error</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/G…
2372 <li><code>session</code> <a href="http2.html#class-serverhttp2session" class="type"><ServerHtt…
2374 <p>The <code>'sessionError'</code> event is emitted when an <code>'error'</code> event is emitted by
2375 an <code>Http2Session</code> object associated with the <code>Http2Server</code>.</p>
2376 <h5>Event: <code>'stream'</code><span><a class="mark" href="#event-stream_1" id="event-stream_1">#<…
2381 <li><code>stream</code> <a href="http2.html#class-http2stream" class="type"><Http2Stream></a> …
2382 <li><code>headers</code> <a href="http2.html#headers-object" class="type"><HTTP/2 Headers Obje…
2383 <li><code>flags</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_struct…
2384 <li><code>rawHeaders</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refere…
2387 <p>The <code>'stream'</code> event is emitted when a <code>'stream'</code> event has been emitted by
2388 an <code>Http2Session</code> associated with the server.</p>
2389 <p>See also <a href="#event-stream"><code>Http2Session</code>'s <code>'stream'</code> event</a>.</p>
2390 <pre><code class="language-js"><span class="hljs-keyword">const</span> http2 = <span class="hljs-bu…
2409 });</code> <button class="copy-button">copy</button></pre>
2410 <h5>Event: <code>'timeout'</code><span><a class="mark" href="#event-timeout_2" id="event-timeout_2"…
2422 <p>The <code>'timeout'</code> event is emitted when there is no activity on the Server for
2423 a given number of milliseconds set using <code>http2server.setTimeout()</code>.
2425 <h5><code>server.close([callback])</code><span><a class="mark" href="#serverclosecallback" id="serv…
2430 <li><code>callback</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Referenc…
2434 … down the server, call <a href="#http2sessionclosecallback"><code>http2session.close()</code></a> …
2436 <p>If <code>callback</code> is provided, it is not invoked until all active sessions have been
2438 <a href="net.html#serverclosecallback"><code>net.Server.close()</code></a> for more details.</p>
2439 <h5><code>server.setTimeout([msecs][, callback])</code><span><a class="mark" href="#serversettimeou…
2445 …callback to the <code>callback</code> argument now throws <code>ERR_INVALID_ARG_TYPE</code> instea…
2454 <li><code>msecs</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_struct…
2455 <li><code>callback</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Referenc…
2460 on the <code>Http2Server</code> after <code>msecs</code> milliseconds.</p>
2461 <p>The given callback is registered as a listener on the <code>'timeout'</code> event.</p>
2462 <p>In case if <code>callback</code> is not a function, a new <code>ERR_INVALID_ARG_TYPE</code>
2464 <h5><code>server.timeout</code><span><a class="mark" href="#servertimeout" id="servertimeout">#</a>…
2481 <p>A value of <code>0</code> will disable the timeout behavior on incoming connections.</p>
2484 <h5><code>server.updateSettings([settings])</code><span><a class="mark" href="#serverupdatesettings…
2489 <li><code>settings</code> <a href="http2.html#settings-object" class="type"><HTTP/2 Settings O…
2492 <p>Throws <code>ERR_HTTP2_INVALID_SETTING_VALUE</code> for invalid <code>settings</code> values.</p>
2493 <p>Throws <code>ERR_INVALID_ARG_TYPE</code> for invalid <code>settings</code> argument.</p>
2494 <h4>Class: <code>Http2SecureServer</code><span><a class="mark" href="#class-http2secureserver" id="…
2501 <p>Instances of <code>Http2SecureServer</code> are created using the
2502 <code>http2.createSecureServer()</code> function. The <code>Http2SecureServer</code> class is not
2503 exported directly by the <code>node:http2</code> module.</p>
2504 <h5>Event: <code>'checkContinue'</code><span><a class="mark" href="#event-checkcontinue_1" id="even…
2509 <li><code>request</code> <a href="http2.html#class-http2http2serverrequest" class="type"><http…
2510 <li><code>response</code> <a href="http2.html#class-http2http2serverresponse" class="type"><ht…
2512 …><code>'request'</code></a> listener is registered or <a href="#http2createsecureserveroptions-onr…
2513 is supplied a callback function, the <code>'checkContinue'</code> event is emitted each
2514 time a request with an HTTP <code>Expect: 100-continue</code> is received. If this event
2516 <code>100 Continue</code> as appropriate.</p>
2517 …s event involves calling <a href="#responsewritecontinue"><code>response.writeContinue()</code></a…
2521 <p>When this event is emitted and handled, the <a href="#event-request"><code>'request'</code></a> …
2523 <h5>Event: <code>'connection'</code><span><a class="mark" href="#event-connection_1" id="event-conn…
2528 <li><code>socket</code> <a href="stream.html#class-streamduplex" class="type"><stream.Duplex><…
2531 handshake begins. <code>socket</code> is typically an object of type <a href="net.html#class-netsoc…
2534 into the HTTP server. In that case, any <a href="stream.html#class-streamduplex"><code>Duplex</code…
2535 <h5>Event: <code>'request'</code><span><a class="mark" href="#event-request_1" id="event-request_1"…
2540 <li><code>request</code> <a href="http2.html#class-http2http2serverrequest" class="type"><http…
2541 <li><code>response</code> <a href="http2.html#class-http2http2serverresponse" class="type"><ht…
2545 <h5>Event: <code>'session'</code><span><a class="mark" href="#event-session_1" id="event-session_1"…
2550 <li><code>session</code> <a href="http2.html#class-serverhttp2session" class="type"><ServerHtt…
2552 <p>The <code>'session'</code> event is emitted when a new <code>Http2Session</code> is created by t…
2553 <code>Http2SecureServer</code>.</p>
2554 <h5>Event: <code>'sessionError'</code><span><a class="mark" href="#event-sessionerror_1" id="event-…
2559 <li><code>error</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/G…
2560 <li><code>session</code> <a href="http2.html#class-serverhttp2session" class="type"><ServerHtt…
2562 <p>The <code>'sessionError'</code> event is emitted when an <code>'error'</code> event is emitted by
2563 an <code>Http2Session</code> object associated with the <code>Http2SecureServer</code>.</p>
2564 <h5>Event: <code>'stream'</code><span><a class="mark" href="#event-stream_2" id="event-stream_2">#<…
2569 <li><code>stream</code> <a href="http2.html#class-http2stream" class="type"><Http2Stream></a> …
2570 <li><code>headers</code> <a href="http2.html#headers-object" class="type"><HTTP/2 Headers Obje…
2571 <li><code>flags</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_struct…
2572 <li><code>rawHeaders</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refere…
2575 <p>The <code>'stream'</code> event is emitted when a <code>'stream'</code> event has been emitted by
2576 an <code>Http2Session</code> associated with the server.</p>
2577 <p>See also <a href="#event-stream"><code>Http2Session</code>'s <code>'stream'</code> event</a>.</p>
2578 <pre><code class="language-js"><span class="hljs-keyword">const</span> http2 = <span class="hljs-bu…
2599 });</code> <button class="copy-button">copy</button></pre>
2600 <h5>Event: <code>'timeout'</code><span><a class="mark" href="#event-timeout_3" id="event-timeout_3"…
2604 <p>The <code>'timeout'</code> event is emitted when there is no activity on the Server for
2605 a given number of milliseconds set using <code>http2secureServer.setTimeout()</code>.
2607 <h5>Event: <code>'unknownProtocol'</code><span><a class="mark" href="#event-unknownprotocol" id="ev…
2612 <li><code>socket</code> <a href="stream.html#class-streamduplex" class="type"><stream.Duplex><…
2614 <p>The <code>'unknownProtocol'</code> event is emitted when a connecting client fails to
2618 <code>'unknownProtocolTimeout'</code> option passed to <a href="#http2createsecureserveroptions-onr…
2620 <h5><code>server.close([callback])</code><span><a class="mark" href="#serverclosecallback_1" id="se…
2625 <li><code>callback</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Referenc…
2629 … down the server, call <a href="#http2sessionclosecallback"><code>http2session.close()</code></a> …
2631 <p>If <code>callback</code> is provided, it is not invoked until all active sessions have been
2633 <a href="tls.html#serverclosecallback"><code>tls.Server.close()</code></a> for more details.</p>
2634 <h5><code>server.setTimeout([msecs][, callback])</code><span><a class="mark" href="#serversettimeou…
2640 …callback to the <code>callback</code> argument now throws <code>ERR_INVALID_ARG_TYPE</code> instea…
2647 …code>msecs</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures…
2648 <li><code>callback</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Referenc…
2653 on the <code>Http2SecureServer</code> after <code>msecs</code> milliseconds.</p>
2654 <p>The given callback is registered as a listener on the <code>'timeout'</code> event.</p>
2655 <p>In case if <code>callback</code> is not a function, a new <code>ERR_INVALID_ARG_TYPE</code>
2657 <h5><code>server.timeout</code><span><a class="mark" href="#servertimeout_1" id="servertimeout_1">#…
2674 <p>A value of <code>0</code> will disable the timeout behavior on incoming connections.</p>
2677 <h5><code>server.updateSettings([settings])</code><span><a class="mark" href="#serverupdatesettings…
2682 <li><code>settings</code> <a href="http2.html#settings-object" class="type"><HTTP/2 Settings O…
2685 <p>Throws <code>ERR_HTTP2_INVALID_SETTING_VALUE</code> for invalid <code>settings</code> values.</p>
2686 <p>Throws <code>ERR_INVALID_ARG_TYPE</code> for invalid <code>settings</code> argument.</p>
2687 <h4><code>http2.createServer([options][, onRequestHandler])</code><span><a class="mark" href="#http…
2693 …The <code>PADDING_STRATEGY_CALLBACK</code> has been made equivalent to providing <code>PADDING_STR…
2695 <td><p>Added <code>maxSessionRejectedStreams</code> option with a default of 100.</p></td></tr>
2697 <td><p>Added <code>maxSessionInvalidFrames</code> option with a default of 1000.</p></td></tr>
2699 <td><p>The <code>options</code> parameter now supports <code>net.createServer()</code> options.</p>…
2701 <td><p>Added <code>unknownProtocolTimeout</code> option with a default of 10000.</p></td></tr>
2703 <td><p>Added <code>maxSettings</code> option with a default of 32.</p></td></tr>
2705 <td><p>Added the <code>Http1IncomingMessage</code> and <code>Http1ServerResponse</code> option.</p>…
2707 <td><p>Added the <code>maxOutstandingPings</code> option with a default limit of 10.</p></td></tr>
2709 <td><p>Added the <code>maxHeaderListPairs</code> option with a default limit of 128 header pairs.</…
2716 <li><code>options</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference…
2718 <li><code>maxDeflateDynamicTableSize</code> <a href="https://developer.mozilla.org/en-US/docs/Web/J…
2719 for deflating header fields. <strong>Default:</strong> <code>4Kib</code>.</li>
2720 <li><code>maxSettings</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_…
2721 <code>SETTINGS</code> frame. The minimum value allowed is <code>1</code>. <strong>Default:</strong>…
2722 …code>maxSessionMemory</code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_…
2724 e.g. <code>1</code> equal 1 megabyte. The minimum value allowed is <code>1</code>.
2725 This is a credit based limit, existing <code>Http2Stream</code>s may cause this
2726 limit to be exceeded, but new <code>Http2Stream</code> instances will be rejected
2727 while this limit is exceeded. The current number of <code>Http2Stream</code> sessions,
2729 queued to be sent, and unacknowledged <code>PING</code> and <code>SETTINGS</code> frames are all
2730 counted towards the current limit. <strong>Default:</strong> <code>10</code>.</li>
2731 <li><code>maxHeaderListPairs</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScrip…
2732 This is similar to <a href="http.html#servermaxheaderscount"><code>server.maxHeadersCount</code></a…
2733 … href="http.html#requestmaxheaderscount"><code>request.maxHeadersCount</code></a> in the <code>nod…
2734 is <code>4</code>. <strong>Default:</strong> <code>128</code>.</li>
2735 <li><code>maxOutstandingPings</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScri…
2736 unacknowledged pings. <strong>Default:</strong> <code>10</code>.</li>
2737 <li><code>maxSendHeaderBlockLength</code> <a href="https://developer.mozilla.org/en-US/docs/Web/Jav…
2739 exceed this limit will result in a <code>'frameError'</code> event being emitted
2742 <code>nghttp2</code> (the internal http2 library) has a limit of <code>65536</code>
2744 <li><code>paddingStrategy</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/D…
2745 padding to use for <code>HEADERS</code> and <code>DATA</code> frames. <strong>Default:</strong>
2746 <code>http2.constants.PADDING_STRATEGY_NONE</code>. Value may be one of:
2748 <li><code>http2.constants.PADDING_STRATEGY_NONE</code>: No padding is applied.</li>
2749 <li><code>http2.constants.PADDING_STRATEGY_MAX</code>: The maximum amount of padding,
2751 <li><code>http2.constants.PADDING_STRATEGY_ALIGNED</code>: Attempts to apply enough
2760 <li><code>peerMaxConcurrentStreams</code> <a href="https://developer.mozilla.org/en-US/docs/Web/Jav…
2761 streams for the remote peer as if a <code>SETTINGS</code> frame had been received. Will
2763 <code>maxConcurrentStreams</code>. <strong>Default:</strong> <code>100</code>.</li>
2764 <li><code>maxSessionInvalidFrames</code> <a href="https://developer.mozilla.org/en-US/docs/Web/Java…
2766 <strong>Default:</strong> <code>1000</code>.</li>
2767 <li><code>maxSessionRejectedStreams</code> <a href="https://developer.mozilla.org/en-US/docs/Web/Ja…
2769 Each rejection is associated with an <code>NGHTTP2_ENHANCE_YOUR_CALM</code>
2772 <strong>Default:</strong> <code>100</code>.</li>
2773 <li><code>settings</code> <a href="http2.html#settings-object" class="type"><HTTP/2 Settings O…
2775 <li><code>Http1IncomingMessage</code> <a href="http.html#class-httpincomingmessage" class="type">&#…
2776 <code>IncomingMessage</code> class to used for HTTP/1 fallback. Useful for extending
2777 the original <code>http.IncomingMessage</code>. <strong>Default:</strong> <code>http.IncomingMessag…
2778 …code>Http1ServerResponse</code> <a href="http.html#class-httpserverresponse" class="type"><ht…
2780 <code>http.ServerResponse</code>. <strong>Default:</strong> <code>http.ServerResponse</code>.</li>
2781 <li><code>Http2ServerRequest</code> <a href="http2.html#class-http2http2serverrequest" class="type"…
2782 <code>Http2ServerRequest</code> class to use.
2783 Useful for extending the original <code>Http2ServerRequest</code>.
2784 <strong>Default:</strong> <code>Http2ServerRequest</code>.</li>
2785 <li><code>Http2ServerResponse</code> <a href="http2.html#class-http2http2serverresponse" class="typ…
2786 <code>Http2ServerResponse</code> class to use.
2787 Useful for extending the original <code>Http2ServerResponse</code>.
2788 <strong>Default:</strong> <code>Http2ServerResponse</code>.</li>
2789 <li><code>unknownProtocolTimeout</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaS…
2790 a server should wait when an <a href="#event-unknownprotocol"><code>'unknownProtocol'</code></a> is…
2792 <strong>Default:</strong> <code>10000</code>.</li>
2793 …<a href="net.html#netcreateserveroptions-connectionlistener"><code>net.createServer()</code></a> o…
2796 <li><code>onRequestHandler</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/…
2799 <p>Returns a <code>net.Server</code> instance that creates and manages <code>Http2Session</code>
2803 <a href="#http2createsecureserveroptions-onrequesthandler"><code>http2.createSecureServer()</code><…
2805 <pre><code class="language-js"><span class="hljs-keyword">const</span> http2 = <span class="hljs-bu…
2821 …s-title function_">listen</span>(<span class="hljs-number">8000</span>);</code> <button class="cop…
2822 <h4><code>http2.createSecureServer(options[, onRequestHandler])</code><span><a class="mark" href="#…
2828 …The <code>PADDING_STRATEGY_CALLBACK</code> has been made equivalent to providing <code>PADDING_STR…
2830 <td><p>Added <code>maxSessionRejectedStreams</code> option with a default of 100.</p></td></tr>
2832 <td><p>Added <code>maxSessionInvalidFrames</code> option with a default of 1000.</p></td></tr>
2834 <td><p>Added <code>unknownProtocolTimeout</code> option with a default of 10000.</p></td></tr>
2836 <td><p>Added <code>maxSettings</code> option with a default of 32.</p></td></tr>
2838 <td><p>Added the <code>origins</code> option to automatically send an <code>ORIGIN</code> frame on …
2840 <td><p>Added the <code>maxOutstandingPings</code> option with a default limit of 10.</p></td></tr>
2842 <td><p>Added the <code>maxHeaderListPairs</code> option with a default limit of 128 header pairs.</…
2849 <li><code>options</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference…
2851 <li><code>allowHTTP1</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_s…
2852 HTTP/2 will be downgraded to HTTP/1.x when set to <code>true</code>.
2853 See the <a href="#event-unknownprotocol"><code>'unknownProtocol'</code></a> event. See <a href="#al…
2854 <strong>Default:</strong> <code>false</code>.</li>
2855 <li><code>maxDeflateDynamicTableSize</code> <a href="https://developer.mozilla.org/en-US/docs/Web/J…
2856 for deflating header fields. <strong>Default:</strong> <code>4Kib</code>.</li>
2857 <li><code>maxSettings</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_…
2858 <code>SETTINGS</code> frame. The minimum value allowed is <code>1</code>. <strong>Default:</strong>…
2859 …code>maxSessionMemory</code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_…
2861 e.g. <code>1</code> equal 1 megabyte. The minimum value allowed is <code>1</code>. This is a
2862 credit based limit, existing <code>Http2Stream</code>s may cause this
2863 limit to be exceeded, but new <code>Http2Stream</code> instances will be rejected
2864 while this limit is exceeded. The current number of <code>Http2Stream</code> sessions,
2866 queued to be sent, and unacknowledged <code>PING</code> and <code>SETTINGS</code> frames are all
2867 counted towards the current limit. <strong>Default:</strong> <code>10</code>.</li>
2868 <li><code>maxHeaderListPairs</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScrip…
2869 This is similar to <a href="http.html#servermaxheaderscount"><code>server.maxHeadersCount</code></a…
2870 … href="http.html#requestmaxheaderscount"><code>request.maxHeadersCount</code></a> in the <code>nod…
2871 is <code>4</code>. <strong>Default:</strong> <code>128</code>.</li>
2872 <li><code>maxOutstandingPings</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScri…
2873 unacknowledged pings. <strong>Default:</strong> <code>10</code>.</li>
2874 <li><code>maxSendHeaderBlockLength</code> <a href="https://developer.mozilla.org/en-US/docs/Web/Jav…
2876 exceed this limit will result in a <code>'frameError'</code> event being emitted
2878 <li><code>paddingStrategy</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/D…
2879 padding to use for <code>HEADERS</code> and <code>DATA</code> frames. <strong>Default:</strong>
2880 <code>http2.constants.PADDING_STRATEGY_NONE</code>. Value may be one of:
2882 <li><code>http2.constants.PADDING_STRATEGY_NONE</code>: No padding is applied.</li>
2883 <li><code>http2.constants.PADDING_STRATEGY_MAX</code>: The maximum amount of padding,
2885 <li><code>http2.constants.PADDING_STRATEGY_ALIGNED</code>: Attempts to apply enough
2894 <li><code>peerMaxConcurrentStreams</code> <a href="https://developer.mozilla.org/en-US/docs/Web/Jav…
2895 streams for the remote peer as if a <code>SETTINGS</code> frame had been received. Will
2897 <code>maxConcurrentStreams</code>. <strong>Default:</strong> <code>100</code>.</li>
2898 <li><code>maxSessionInvalidFrames</code> <a href="https://developer.mozilla.org/en-US/docs/Web/Java…
2900 <strong>Default:</strong> <code>1000</code>.</li>
2901 <li><code>maxSessionRejectedStreams</code> <a href="https://developer.mozilla.org/en-US/docs/Web/Ja…
2903 Each rejection is associated with an <code>NGHTTP2_ENHANCE_YOUR_CALM</code>
2906 <strong>Default:</strong> <code>100</code>.</li>
2907 <li><code>settings</code> <a href="http2.html#settings-object" class="type"><HTTP/2 Settings O…
2909 …f="tls.html#tlscreateserveroptions-secureconnectionlistener"><code>tls.createServer()</code></a> o…
2910 servers, the identity options (<code>pfx</code> or <code>key</code>/<code>cert</code>) are usually …
2911 …code>origins</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structur…
2912 frame immediately following creation of a new server <code>Http2Session</code>.</li>
2913 <li><code>unknownProtocolTimeout</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaS…
2914 a server should wait when an <a href="#event-unknownprotocol"><code>'unknownProtocol'</code></a> ev…
2916 <strong>Default:</strong> <code>10000</code>.</li>
2919 <li><code>onRequestHandler</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/…
2922 <p>Returns a <code>tls.Server</code> instance that creates and manages <code>Http2Session</code>
2924 <pre><code class="language-js"><span class="hljs-keyword">const</span> http2 = <span class="hljs-bu…
2943 …s-title function_">listen</span>(<span class="hljs-number">8443</span>);</code> <button class="cop…
2944 <h4><code>http2.connect(authority[, options][, listener])</code><span><a class="mark" href="#http2c…
2950 …The <code>PADDING_STRATEGY_CALLBACK</code> has been made equivalent to providing <code>PADDING_STR…
2952 <td><p>Added <code>unknownProtocolTimeout</code> option with a default of 10000.</p></td></tr>
2954 <td><p>Added <code>maxSettings</code> option with a default of 32.</p></td></tr>
2956 <td><p>Added the <code>maxOutstandingPings</code> option with a default limit of 10.</p></td></tr>
2958 <td><p>Added the <code>maxHeaderListPairs</code> option with a default limit of 128 header pairs.</…
2965 <li><code>authority</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_st…
2966 be in the form of a minimal, valid URL with the <code>http://</code> or <code>https://</code>
2970 <li><code>options</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference…
2972 <li><code>maxDeflateDynamicTableSize</code> <a href="https://developer.mozilla.org/en-US/docs/Web/J…
2973 for deflating header fields. <strong>Default:</strong> <code>4Kib</code>.</li>
2974 <li><code>maxSettings</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_…
2975 <code>SETTINGS</code> frame. The minimum value allowed is <code>1</code>. <strong>Default:</strong>…
2976 …code>maxSessionMemory</code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_…
2978 e.g. <code>1</code> equal 1 megabyte. The minimum value allowed is <code>1</code>.
2979 This is a credit based limit, existing <code>Http2Stream</code>s may cause this
2980 limit to be exceeded, but new <code>Http2Stream</code> instances will be rejected
2981 while this limit is exceeded. The current number of <code>Http2Stream</code> sessions,
2983 queued to be sent, and unacknowledged <code>PING</code> and <code>SETTINGS</code> frames are all
2984 counted towards the current limit. <strong>Default:</strong> <code>10</code>.</li>
2985 <li><code>maxHeaderListPairs</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScrip…
2986 This is similar to <a href="http.html#servermaxheaderscount"><code>server.maxHeadersCount</code></a…
2987 … href="http.html#requestmaxheaderscount"><code>request.maxHeadersCount</code></a> in the <code>nod…
2988 is <code>1</code>. <strong>Default:</strong> <code>128</code>.</li>
2989 <li><code>maxOutstandingPings</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScri…
2990 unacknowledged pings. <strong>Default:</strong> <code>10</code>.</li>
2991 <li><code>maxReservedRemoteStreams</code> <a href="https://developer.mozilla.org/en-US/docs/Web/Jav…
2996 this option to the maximum allowed value. <strong>Default:</strong> <code>200</code>.</li>
2997 <li><code>maxSendHeaderBlockLength</code> <a href="https://developer.mozilla.org/en-US/docs/Web/Jav…
2999 exceed this limit will result in a <code>'frameError'</code> event being emitted
3001 <li><code>paddingStrategy</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/D…
3002 padding to use for <code>HEADERS</code> and <code>DATA</code> frames. <strong>Default:</strong>
3003 <code>http2.constants.PADDING_STRATEGY_NONE</code>. Value may be one of:
3005 <li><code>http2.constants.PADDING_STRATEGY_NONE</code>: No padding is applied.</li>
3006 <li><code>http2.constants.PADDING_STRATEGY_MAX</code>: The maximum amount of padding,
3008 <li><code>http2.constants.PADDING_STRATEGY_ALIGNED</code>: Attempts to apply enough
3017 <li><code>peerMaxConcurrentStreams</code> <a href="https://developer.mozilla.org/en-US/docs/Web/Jav…
3018 streams for the remote peer as if a <code>SETTINGS</code> frame had been received. Will
3020 <code>maxConcurrentStreams</code>. <strong>Default:</strong> <code>100</code>.</li>
3021 <li><code>protocol</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_str…
3022 <code>authority</code>. Value may be either <code>'http:'</code> or <code>'https:'</code>. <strong>…
3023 <code>'https:'</code></li>
3024 <li><code>settings</code> <a href="http2.html#settings-object" class="type"><HTTP/2 Settings O…
3026 …code>createConnection</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe…
3027 instance passed to <code>connect</code> and the <code>options</code> object, and returns any
3028 <a href="stream.html#class-streamduplex"><code>Duplex</code></a> stream that is to be used as the c…
3029 …="net.html#netconnect"><code>net.connect()</code></a> or <a href="tls.html#tlsconnectoptions-callb…
3030 <li><code>unknownProtocolTimeout</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaS…
3031 a server should wait when an <a href="#event-unknownprotocol"><code>'unknownProtocol'</code></a> ev…
3033 <strong>Default:</strong> <code>10000</code>.</li>
3036 <li><code>listener</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Referenc…
3037 <a href="#event-connect"><code>'connect'</code></a> event.</li>
3040 <p>Returns a <code>ClientHttp2Session</code> instance.</p>
3041 <pre><code class="language-js"><span class="hljs-keyword">const</span> http2 = <span class="hljs-bu…
3046 client.<span class="hljs-title function_">close</span>();</code> <button class="copy-button">copy</…
3047 <h4><code>http2.constants</code><span><a class="mark" href="#http2constants" id="http2constants">#<…
3051 <h5>Error codes for <code>RST_STREAM</code> and <code>GOAWAY</code><span><a class="mark" href="#err…
3132 …code>0x00</code></td><td>No Error</td><td><code>http2.constants.NGHTTP2_NO_ERROR</code></td></tr><…
3133 <p>The <code>'timeout'</code> event is emitted when there is no activity on the Server for
3134 a given number of milliseconds set using <code>http2server.setTimeout()</code>.</p>
3135 <h4><code>http2.getDefaultSettings()</code><span><a class="mark" href="#http2getdefaultsettings" id…
3142 <p>Returns an object containing the default settings for an <code>Http2Session</code>
3145 <h4><code>http2.getPackedSettings([settings])</code><span><a class="mark" href="#http2getpackedsett…
3150 <li><code>settings</code> <a href="http2.html#settings-object" class="type"><HTTP/2 Settings O…
3153 <p>Returns a <code>Buffer</code> instance containing serialized representation of the given
3155 for use with the <code>HTTP2-Settings</code> header field.</p>
3156 <pre><code class="language-js"><span class="hljs-keyword">const</span> http2 = <span class="hljs-bu…
3161 <span class="hljs-comment">// Prints: AAIAAAAA</span></code> <button class="copy-button">copy</butt…
3162 <h4><code>http2.getUnpackedSettings(buf)</code><span><a class="mark" href="#http2getunpackedsetting…
3167 <li><code>buf</code> <a href="buffer.html#class-buffer" class="type"><Buffer></a> | <a href="h…
3171 the given <code>Buffer</code> as generated by <code>http2.getPackedSettings()</code>.</p>
3172 <h4><code>http2.sensitiveHeaders</code><span><a class="mark" href="#http2sensitiveheaders" id="http…
3185 they are not they will be coerced to strings) or an <code>Array</code> of strings (in order
3187 <pre><code class="language-js"><span class="hljs-keyword">const</span> headers = {
3193 stream.<span class="hljs-title function_">respond</span>(headers);</code> <button class="copy-butto…
3194 <p>Header objects passed to callback functions will have a <code>null</code> prototype. This
3196 <code>Object.prototype.toString()</code> and <code>Object.prototype.hasOwnProperty()</code> will
3200 <li>The <code>:status</code> header is converted to <code>number</code>.</li>
3201 <li>Duplicates of <code>:status</code>, <code>:method</code>, <code>:authority</code>, <code>:schem…
3202 <code>:protocol</code>, <code>age</code>, <code>authorization</code>, <code>access-control-allow-cr…
3203 <code>access-control-max-age</code>, <code>access-control-request-method</code>, <code>content-enco…
3204 <code>content-language</code>, <code>content-length</code>, <code>content-location</code>, <code>co…
3205 <code>content-range</code>, <code>content-type</code>, <code>date</code>, <code>dnt</code>, <code>e…
3206 <code>host</code>, <code>if-match</code>, <code>if-modified-since</code>, <code>if-none-match</code…
3207 <code>if-unmodified-since</code>, <code>last-modified</code>, <code>location</code>, <code>max-forw…
3208 <code>proxy-authorization</code>, <code>range</code>, <code>referer</code>,<code>retry-after</code>…
3209 <code>upgrade-insecure-requests</code>, <code>user-agent</code> or <code>x-content-type-options</co…
3211 <li><code>set-cookie</code> is always an array. Duplicates are added to the array.</li>
3212 <li>For duplicate <code>cookie</code> headers, the values are joined together with '; '.</li>
3215 <pre><code class="language-js"><span class="hljs-keyword">const</span> http2 = <span class="hljs-bu…
3220 });</code> <button class="copy-button">copy</button></pre>
3225 attacker, for example <code>Cookie</code> or <code>Authorization</code>. To achieve this, add
3226 the header name to the <code>[http2.sensitiveHeaders]</code> property as an array:</p>
3227 <pre><code class="language-js"><span class="hljs-keyword">const</span> headers = {
3235 stream.<span class="hljs-title function_">respond</span>(headers);</code> <button class="copy-butto…
3236 <p>For some headers, such as <code>Authorization</code> and short <code>Cookie</code> headers,
3246 <td><p>The <code>maxConcurrentStreams</code> setting is stricter.</p></td></tr>
3248 <td><p>The <code>maxHeaderListSize</code> setting is now strictly enforced.</p></td></tr>
3254 <p>The <code>http2.getDefaultSettings()</code>, <code>http2.getPackedSettings()</code>,
3255 <code>http2.createServer()</code>, <code>http2.createSecureServer()</code>,
3256 <code>http2session.settings()</code>, <code>http2session.localSettings</code>, and
3257 <code>http2session.remoteSettings</code> APIs either return or receive as input an
3258 object that defines configuration settings for an <code>Http2Session</code> object.
3262 <li><code>headerTableSize</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/D…
3264 is 2<sup>32</sup>-1. <strong>Default:</strong> <code>4096</code>.</li>
3265 …code>enablePush</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_struc…
3266 permitted on the <code>Http2Session</code> instances. <strong>Default:</strong> <code>true</code>.<…
3267 <li><code>initialWindowSize</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript…
3269 maximum allowed value is 2<sup>32</sup>-1. <strong>Default:</strong> <code>65535</code>.</li>
3270 <li><code>maxFrameSize</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data…
3272 2<sup>24</sup>-1. <strong>Default:</strong> <code>16384</code>.</li>
3273 <li><code>maxConcurrentStreams</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScr…
3274 streams permitted on an <code>Http2Session</code>. There is no default value which
3276 concurrently at any given time in an <code>Http2Session</code>. The minimum value
3278 <code>4294967295</code>.</li>
3279 <li><code>maxHeaderListSize</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript…
3281 maximum allowed value is 2<sup>32</sup>-1. <strong>Default:</strong> <code>65535</code>.</li>
3282 …code>maxHeaderSize</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_st…
3283 …code>enableConnectProtocol</code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/…
3285 meaningful if sent by the server. Once the <code>enableConnectProtocol</code> setting
3286 has been enabled for a given <code>Http2Session</code>, it cannot be disabled.
3287 <strong>Default:</strong> <code>false</code>.</li>
3292 <code>node:http2</code> module:</p>
3294 passed in. These will always be reported by a synchronous <code>throw</code>.</p>
3297 be reported using either a synchronous <code>throw</code> or via an <code>'error'</code> event on
3298 the <code>Http2Stream</code>, <code>Http2Session</code> or HTTP/2 Server objects, depending on where
3301 reported via an <code>'error'</code> event on the <code>Http2Session</code> or HTTP/2 Server object…
3303 These will be reported using either a synchronous <code>throw</code> or via an <code>'error'</code>
3304 event on the <code>Http2Stream</code>, <code>Http2Session</code> or HTTP/2 Server objects, depending
3311 names to be set as mixed-case strings (e.g. <code>Content-Type</code>) but will convert
3312 those to lower-case (e.g. <code>content-type</code>) upon transmission.</p>
3314 …code>a</code>-<code>z</code>, <code>A</code>-<code>Z</code>, <code>0</code>-<code>9</code>, <code>…
3315 <code>-</code>, <code>.</code>, <code>^</code>, <code>_</code>, <code>`</code> (backtick), <code>|<…
3322 <p>To receive pushed streams on the client, set a listener for the <code>'stream'</code>
3323 event on the <code>ClientHttp2Session</code>:</p>
3324 <pre><code class="language-js"><span class="hljs-keyword">const</span> http2 = <span class="hljs-bu…
3335 …s="hljs-string">':path'</span>: <span class="hljs-string">'/'</span> });</code> <button class="cop…
3336 <h4>Supporting the <code>CONNECT</code> method<span><a class="mark" href="#supporting-the-connect-m…
3337 <p>The <code>CONNECT</code> method is used to allow an HTTP/2 server to be used as a proxy
3340 <pre><code class="language-js"><span class="hljs-keyword">const</span> net = <span class="hljs-buil…
3349 …s-title function_">listen</span>(<span class="hljs-number">8000</span>);</code> <button class="cop…
3351 <pre><code class="language-js"><span class="hljs-keyword">const</span> http2 = <span class="hljs-bu…
3375 …s-title function_">listen</span>(<span class="hljs-number">8001</span>);</code> <button class="cop…
3377 <pre><code class="language-js"><span class="hljs-keyword">const</span> http2 = <span class="hljs-bu…
3398 req.<span class="hljs-title function_">end</span>(<span class="hljs-string">'Jane'</span>);</code> …
3399 <h4>The extended <code>CONNECT</code> protocol<span><a class="mark" href="#the-extended-connect-pro…
3401 may be used to bootstrap the use of an <code>Http2Stream</code> using the <code>CONNECT</code>
3404 the <code>enableConnectProtocol</code> setting:</p>
3405 <pre><code class="language-js"><span class="hljs-keyword">const</span> http2 = <span class="hljs-bu…
3407 …p2.<span class="hljs-title function_">createServer</span>({ settings });</code> <button class="cop…
3408 <p>Once the client receives the <code>SETTINGS</code> frame from the server indicating that
3409 the extended CONNECT may be used, it may send <code>CONNECT</code> requests that use the
3410 <code>':protocol'</code> HTTP/2 pseudo-header:</p>
3411 <pre><code class="language-js"><span class="hljs-keyword">const</span> http2 = <span class="hljs-bu…
3418 });</code> <button class="copy-button">copy</button></pre>
3428 <pre><code class="language-js"><span class="hljs-keyword">const</span> http2 = <span class="hljs-bu…
3434 });</code> <button class="copy-button">copy</button></pre>
3438 … API is composed of <a href="#class-http2http2serverrequest"><code>Http2ServerRequest</code></a> a…
3439 <a href="#class-http2http2serverresponse"><code>Http2ServerResponse</code></a>. They aim at API com…
3444 the same socket. The <code>req</code> and <code>res</code> objects can be either HTTP/1 or
3449 <pre><code class="language-js"><span class="hljs-keyword">const</span> { createSecureServer } = <sp…
3469 }</code> <button class="copy-button">copy</button></pre>
3470 <p>The <code>'request'</code> event works identically on both <a href="https.html">HTTPS</a> and
3472 <h4>Class: <code>http2.Http2ServerRequest</code><span><a class="mark" href="#class-http2http2server…
3479 <p>A <code>Http2ServerRequest</code> object is created by <a href="#class-http2server"><code>http2.…
3480 <a href="#class-http2secureserver"><code>http2.SecureServer</code></a> and passed as the first argu…
3481 <a href="#event-request"><code>'request'</code></a> event. It may be used to access a request statu…
3483 <h5>Event: <code>'aborted'</code><span><a class="mark" href="#event-aborted_1" id="event-aborted_1"…
3487 <p>The <code>'aborted'</code> event is emitted whenever a <code>Http2ServerRequest</code> instance …
3489 <p>The <code>'aborted'</code> event will only be emitted if the <code>Http2ServerRequest</code> wri…
3491 <h5>Event: <code>'close'</code><span><a class="mark" href="#event-close_2" id="event-close_2">#</a>…
3495 <p>Indicates that the underlying <a href="#class-http2stream"><code>Http2Stream</code></a> was clos…
3496 Just like <code>'end'</code>, this event occurs only once per response.</p>
3497 <h5><code>request.aborted</code><span><a class="mark" href="#requestaborted" id="requestaborted">#<…
3504 <p>The <code>request.aborted</code> property will be <code>true</code> if the request has
3506 <h5><code>request.authority</code><span><a class="mark" href="#requestauthority" id="requestauthori…
3514 to set either <code>:authority</code> or <code>host</code>, this value is derived from
3515 <code>req.headers[':authority']</code> if present. Otherwise, it is derived from
3516 <code>req.headers['host']</code>.</p>
3517 <h5><code>request.complete</code><span><a class="mark" href="#requestcomplete" id="requestcomplete"…
3524 <p>The <code>request.complete</code> property will be <code>true</code> if the request has
3526 <h5><code>request.connection</code><span><a class="mark" href="#requestconnection" id="requestconne…
3530 …x">Stability: 0</a> - Deprecated. Use <a href="#requestsocket"><code>request.socket</code></a>.</d…
3534 <p>See <a href="#requestsocket"><code>request.socket</code></a>.</p>
3535 <h5><code>request.destroy([error])</code><span><a class="mark" href="#requestdestroyerror" id="requ…
3540 <li><code>error</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/G…
3542 <p>Calls <code>destroy()</code> on the <a href="#class-http2stream"><code>Http2Stream</code></a> th…
3543 …ass-http2http2serverrequest"><code>Http2ServerRequest</code></a>. If <code>error</code> is provide…
3544 is emitted and <code>error</code> is passed as an argument to any listeners on the event.</p>
3546 <h5><code>request.headers</code><span><a class="mark" href="#requestheaders" id="requestheaders">#<…
3555 <pre><code class="language-js"><span class="hljs-comment">// Prints something like:</span>
3560 …nction_">log</span>(request.<span class="hljs-property">headers</span>);</code> <button class="cop…
3563 special headers prefixed with the <code>:</code> character (e.g. <code>':path'</code>). These speci…
3564 headers will be included in the <code>request.headers</code> object. Care must be taken not
3567 <pre><code class="language-js"><span class="hljs-title function_">removeAllHeaders</span>(request.<…
3568 …"hljs-comment">// Fails because the :path header has been removed</span></code> <button class="cop…
3569 <h5><code>request.httpVersion</code><span><a class="mark" href="#requesthttpversion" id="requesthtt…
3578 <code>'2.0'</code>.</p>
3579 <p>Also <code>message.httpVersionMajor</code> is the first integer and
3580 <code>message.httpVersionMinor</code> is the second.</p>
3581 <h5><code>request.method</code><span><a class="mark" href="#requestmethod" id="requestmethod">#</a>…
3588 <p>The request method as a string. Read-only. Examples: <code>'GET'</code>, <code>'DELETE'</code>.<…
3589 <h5><code>request.rawHeaders</code><span><a class="mark" href="#requestrawheaders" id="requestrawhe…
3601 <pre><code class="language-js"><span class="hljs-comment">// Prints something like:</span>
3611 …ion_">log</span>(request.<span class="hljs-property">rawHeaders</span>);</code> <button class="cop…
3612 <h5><code>request.rawTrailers</code><span><a class="mark" href="#requestrawtrailers" id="requestraw…
3620 received. Only populated at the <code>'end'</code> event.</p>
3621 <h5><code>request.scheme</code><span><a class="mark" href="#requestscheme" id="requestscheme">#</a>…
3630 <h5><code>request.setTimeout(msecs, callback)</code><span><a class="mark" href="#requestsettimeoutm…
3635 <li><code>msecs</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_struct…
3636 <li><code>callback</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Referenc…
3639 <p>Sets the <a href="#class-http2stream"><code>Http2Stream</code></a>'s timeout value to <code>msec…
3640 provided, then it is added as a listener on the <code>'timeout'</code> event on
3642 <p>If no <code>'timeout'</code> listener is added to the request, the response, or
3643 the server, then <a href="#class-http2stream"><code>Http2Stream</code></a>s are destroyed when they…
3644 handler is assigned to the request, the response, or the server's <code>'timeout'</code>
3646 <h5><code>request.socket</code><span><a class="mark" href="#requestsocket" id="requestsocket">#</a>…
3653 <p>Returns a <code>Proxy</code> object that acts as a <code>net.Socket</code> (or <code>tls.TLSSock…
3655 <p><code>destroyed</code>, <code>readable</code>, and <code>writable</code> properties will be retr…
3656 set on <code>request.stream</code>.</p>
3657 <p><code>destroy</code>, <code>emit</code>, <code>end</code>, <code>on</code> and <code>once</code>…
3658 <code>request.stream</code>.</p>
3659 <p><code>setTimeout</code> method will be called on <code>request.stream.session</code>.</p>
3660 <p><code>pause</code>, <code>read</code>, <code>resume</code>, and <code>write</code> will throw an…
3661 <code>ERR_HTTP2_NO_SOCKET_MANIPULATION</code>. See <a href="#http2session-and-sockets"><code>Http2S…
3664 …href="tls.html#tlssocketgetpeercertificatedetailed"><code>request.socket.getPeerCertificate()</cod…
3666 <h5><code>request.stream</code><span><a class="mark" href="#requeststream" id="requeststream">#</a>…
3673 <p>The <a href="#class-http2stream"><code>Http2Stream</code></a> object backing the request.</p>
3674 <h5><code>request.trailers</code><span><a class="mark" href="#requesttrailers" id="requesttrailers"…
3681 <p>The request/response trailers object. Only populated at the <code>'end'</code> event.</p>
3682 <h5><code>request.url</code><span><a class="mark" href="#requesturl" id="requesturl">#</a></span><a…
3691 <pre><code class="language-http"><span class="hljs-keyword">GET</span> <span class="hljs-string">/s…
3692 <span class="hljs-attribute">Accept</span><span class="hljs-punctuation">: </span>text/plain</code>…
3693 <p>Then <code>request.url</code> will be:</p>
3695 <pre><code class="language-js"><span class="hljs-string">'/status?name=ryan'</span></code> <button …
3696 <p>To parse the url into its parts, <code>new URL()</code> can be used:</p>
3697 <pre><code class="language-console"><span class="hljs-meta prompt_">$ </span><span class="language-…
3712 }</code> <button class="copy-button">copy</button></pre>
3713 <h4>Class: <code>http2.Http2ServerResponse</code><span><a class="mark" href="#class-http2http2serve…
3721 passed as the second parameter to the <a href="#event-request"><code>'request'</code></a> event.</p>
3722 <h5>Event: <code>'close'</code><span><a class="mark" href="#event-close_3" id="event-close_3">#</a>…
3726 <p>Indicates that the underlying <a href="#class-http2stream"><code>Http2Stream</code></a> was term…
3727 <a href="#responseenddata-encoding-callback"><code>response.end()</code></a> was called or able to …
3728 <h5>Event: <code>'finish'</code><span><a class="mark" href="#event-finish" id="event-finish">#</a><…
3737 <h5><code>response.addTrailers(headers)</code><span><a class="mark" href="#responseaddtrailersheade…
3742 <li><code>headers</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference…
3747 will result in a <a href="errors.html#class-typeerror"><code>TypeError</code></a> being thrown.</p>
3748 <h5><code>response.connection</code><span><a class="mark" href="#responseconnection" id="responseco…
3752 …>Stability: 0</a> - Deprecated. Use <a href="#responsesocket"><code>response.socket</code></a>.</d…
3756 <p>See <a href="#responsesocket"><code>response.socket</code></a>.</p>
3757 <h5><code>response.createPushResponse(headers, callback)</code><span><a class="mark" href="#respons…
3763 …callback to the <code>callback</code> argument now throws <code>ERR_INVALID_ARG_TYPE</code> instea…
3770 <li><code>headers</code> <a href="http2.html#headers-object" class="type"><HTTP/2 Headers Obje…
3771 …code>callback</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Gl…
3772 or either when the attempt to create the pushed <code>Http2Stream</code> has failed or
3773 has been rejected, or the state of <code>Http2ServerRequest</code> is closed prior to
3774 calling the <code>http2stream.pushStream()</code> method
3776 <li><code>err</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Glo…
3777 …code>res</code> <a href="http2.html#class-http2http2serverresponse" class="type"><http2.Http2…
3782 … <a href="#http2streampushstreamheaders-options-callback"><code>http2stream.pushStream()</code></a…
3783 given <a href="#class-http2stream"><code>Http2Stream</code></a> on a newly created <code>Http2Serve…
3784 parameter if successful. When <code>Http2ServerRequest</code> is closed, the callback is
3785 called with an error <code>ERR_HTTP2_INVALID_STREAM</code>.</p>
3786 <h5><code>response.end([data[, encoding]][, callback])</code><span><a class="mark" href="#responsee…
3792 <td><p>This method now returns a reference to <code>ServerResponse</code>.</p></td></tr>
3799 <li><code>data</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structu…
3800 <li><code>encoding</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_str…
3801 <li><code>callback</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Referenc…
3806 The method, <code>response.end()</code>, MUST be called on each response.</p>
3807 <p>If <code>data</code> is specified, it is equivalent to calling
3808 …ritechunk-encoding-callback"><code>response.write(data, encoding)</code></a> followed by <code>res…
3809 <p>If <code>callback</code> is specified, it will be called when the response stream
3811 <h5><code>response.finished</code><span><a class="mark" href="#responsefinished" id="responsefinish…
3815 …: 0</a> - Deprecated. Use <a href="#responsewritableended"><code>response.writableEnded</code></a>…
3820 …s <code>false</code>. After <a href="#responseenddata-encoding-callback"><code>response.end()</cod…
3821 <h5><code>response.getHeader(name)</code><span><a class="mark" href="#responsegetheadername" id="re…
3826 <li><code>name</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structu…
3831 …code class="language-js"><span class="hljs-keyword">const</span> contentType = response.<span clas…
3832 <h5><code>response.getHeaderNames()</code><span><a class="mark" href="#responsegetheadernames" id="…
3841 <pre><code class="language-js">response.<span class="hljs-title function_">setHeader</span>(<span c…
3845 <span class="hljs-comment">// headerNames === ['foo', 'set-cookie']</span></code> <button class="co…
3846 <h5><code>response.getHeaders()</code><span><a class="mark" href="#responsegetheaders" id="response…
3858 <p>The object returned by the <code>response.getHeaders()</code> method <em>does not</em>
3859 prototypically inherit from the JavaScript <code>Object</code>. This means that typical
3860 <code>Object</code> methods such as <code>obj.toString()</code>, <code>obj.hasOwnProperty()</code>,…
3862 <pre><code class="language-js">response.<span class="hljs-title function_">setHeader</span>(<span c…
3866 … headers === { foo: 'bar', 'set-cookie': ['foo=bar', 'bar=baz'] }</span></code> <button class="cop…
3867 <h5><code>response.hasHeader(name)</code><span><a class="mark" href="#responsehasheadername" id="re…
3872 <li><code>name</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structu…
3875 <p>Returns <code>true</code> if the header identified by <code>name</code> is currently set in the
3877 …code class="language-js"><span class="hljs-keyword">const</span> hasContentType = response.<span c…
3878 <h5><code>response.headersSent</code><span><a class="mark" href="#responseheaderssent" id="response…
3886 <h5><code>response.removeHeader(name)</code><span><a class="mark" href="#responseremoveheadername" …
3891 <li><code>name</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structu…
3894 …><code class="language-js">response.<span class="hljs-title function_">removeHeader</span>(<span c…
3895 <h5><code>response.req</code><span><a class="mark" href="#responsereq" id="responsereq">#</a></span…
3902 <p>A reference to the original HTTP2 <code>request</code> object.</p>
3903 <h5><code>response.sendDate</code><span><a class="mark" href="#responsesenddate" id="responsesendda…
3914 <h5><code>response.setHeader(name, value)</code><span><a class="mark" href="#responsesetheadername-…
3919 <li><code>name</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structu…
3920 <li><code>value</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_struct…
3925 …code class="language-js">response.<span class="hljs-title function_">setHeader</span>(<span class=…
3927 …code class="language-js">response.<span class="hljs-title function_">setHeader</span>(<span class=…
3929 will result in a <a href="errors.html#class-typeerror"><code>TypeError</code></a> being thrown.</p>
3930 …s have been set with <a href="#responsesetheadername-value"><code>response.setHeader()</code></a>,…
3931 …a href="#responsewriteheadstatuscode-statusmessage-headers"><code>response.writeHead()</code></a>,…
3932 to <a href="#responsewriteheadstatuscode-statusmessage-headers"><code>response.writeHead()</code></…
3933 <pre><code class="language-js"><span class="hljs-comment">// Returns content-type = text/plain</spa…
3939 });</code> <button class="copy-button">copy</button></pre>
3940 <h5><code>response.setTimeout(msecs[, callback])</code><span><a class="mark" href="#responsesettime…
3945 <li><code>msecs</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_struct…
3946 <li><code>callback</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Referenc…
3949 <p>Sets the <a href="#class-http2stream"><code>Http2Stream</code></a>'s timeout value to <code>msec…
3950 provided, then it is added as a listener on the <code>'timeout'</code> event on
3952 <p>If no <code>'timeout'</code> listener is added to the request, the response, or
3953 the server, then <a href="#class-http2stream"><code>Http2Stream</code></a>s are destroyed when they…
3954 handler is assigned to the request, the response, or the server's <code>'timeout'</code>
3956 <h5><code>response.socket</code><span><a class="mark" href="#responsesocket" id="responsesocket">#<…
3963 <p>Returns a <code>Proxy</code> object that acts as a <code>net.Socket</code> (or <code>tls.TLSSock…
3965 <p><code>destroyed</code>, <code>readable</code>, and <code>writable</code> properties will be retr…
3966 set on <code>response.stream</code>.</p>
3967 <p><code>destroy</code>, <code>emit</code>, <code>end</code>, <code>on</code> and <code>once</code>…
3968 <code>response.stream</code>.</p>
3969 <p><code>setTimeout</code> method will be called on <code>response.stream.session</code>.</p>
3970 <p><code>pause</code>, <code>read</code>, <code>resume</code>, and <code>write</code> will throw an…
3971 <code>ERR_HTTP2_NO_SOCKET_MANIPULATION</code>. See <a href="#http2session-and-sockets"><code>Http2S…
3974 <pre><code class="language-js"><span class="hljs-keyword">const</span> http2 = <span class="hljs-bu…
3979 }).<span class="hljs-title function_">listen</span>(<span class="hljs-number">3000</span>);</code> …
3980 <h5><code>response.statusCode</code><span><a class="mark" href="#responsestatuscode" id="responsest…
3987 …a href="#responsewriteheadstatuscode-statusmessage-headers"><code>response.writeHead()</code></a> …
3988 this property controls the status code that will be sent to the client when
3990 <pre><code class="language-js">response.<span class="hljs-property">statusCode</span> = <span class…
3992 status code which was sent out.</p>
3993 <h5><code>response.statusMessage</code><span><a class="mark" href="#responsestatusmessage" id="resp…
4002 <h5><code>response.stream</code><span><a class="mark" href="#responsestream" id="responsestream">#<…
4009 <p>The <a href="#class-http2stream"><code>Http2Stream</code></a> object backing the response.</p>
4010 <h5><code>response.writableEnded</code><span><a class="mark" href="#responsewritableended" id="resp…
4017 <p>Is <code>true</code> after <a href="#responseenddata-encoding-callback"><code>response.end()</co…
4019 <a href="stream.html#writablewritablefinished"><code>writable.writableFinished</code></a> instead.<…
4020 <h5><code>response.write(chunk[, encoding][, callback])</code><span><a class="mark" href="#response…
4025 <li><code>chunk</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_struct…
4026 <li><code>encoding</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_str…
4027 <li><code>callback</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Referenc…
4030 …a href="#responsewriteheadstatuscode-statusmessage-headers"><code>response.writeHead()</code></a> …
4034 <p>In the <code>node:http</code> module, the response body is omitted when the
4035 request is a HEAD request. Similarly, the <code>204</code> and <code>304</code> responses
4037 <p><code>chunk</code> can be a string or a buffer. If <code>chunk</code> is a string,
4039 By default the <code>encoding</code> is <code>'utf8'</code>. <code>callback</code> will be called w…
4043 <p>The first time <a href="#responsewritechunk-encoding-callback"><code>response.write()</code></a>…
4045 time <a href="#responsewritechunk-encoding-callback"><code>response.write()</code></a> is called, N…
4048 <p>Returns <code>true</code> if the entire data was flushed successfully to the kernel
4049 buffer. Returns <code>false</code> if all or part of the data was queued in user memory.
4050 <code>'drain'</code> will be emitted when the buffer is free again.</p>
4051 <h5><code>response.writeContinue()</code><span><a class="mark" href="#responsewritecontinue" id="re…
4055 <p>Sends a status <code>100 Continue</code> to the client, indicating that the request body
4056 …nt. See the <a href="#event-checkcontinue"><code>'checkContinue'</code></a> event on <code>Http2Se…
4057 <code>Http2SecureServer</code>.</p>
4058 <h5><code>response.writeEarlyHints(hints)</code><span><a class="mark" href="#responsewriteearlyhint…
4063 <li><code>hints</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/G…
4065 <p>Sends a status <code>103 Early Hints</code> to the client with a Link header,
4067 The <code>hints</code> is an object containing the values of headers to be sent with
4070 <pre><code class="language-js"><span class="hljs-keyword">const</span> earlyHintsLink = <span class…
4081 });</code> <button class="copy-button">copy</button></pre>
4082 <h5><code>response.writeHead(statusCode[, statusMessage][, headers])</code><span><a class="mark" hr…
4088 <td><p>Return <code>this</code> from <code>writeHead()</code> to allow chaining with <code>end()</c…
4095 <li><code>statusCode</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_s…
4096 <li><code>statusMessage</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Dat…
4097 <li><code>headers</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference…
4100 <p>Sends a response header to the request. The status code is a 3-digit HTTP
4101 status code, like <code>404</code>. The last argument, <code>headers</code>, are the response heade…
4102 <p>Returns a reference to the <code>Http2ServerResponse</code>, so that calls can be chained.</p>
4103 …mpatibility with <a href="http.html">HTTP/1</a>, a human-readable <code>statusMessage</code> may be
4104 passed as the second argument. However, because the <code>statusMessage</code> has no
4107 <pre><code class="language-js"><span class="hljs-keyword">const</span> body = <span class="hljs-str…
4111 });</code> <button class="copy-button">copy</button></pre>
4112 <p><code>Content-Length</code> is given in bytes not characters. The
4113 <code>Buffer.byteLength()</code> API may be used to determine the number of bytes in a
4117 <code>Content-Length</code> does not match the actual payload size.</p>
4119 <a href="#responseenddata-encoding-callback"><code>response.end()</code></a> is called.</p>
4120 …nk-encoding-callback"><code>response.write()</code></a> or <a href="#responseenddata-encoding-call…
4122 …s have been set with <a href="#responsesetheadername-value"><code>response.setHeader()</code></a>,…
4123 …a href="#responsewriteheadstatuscode-statusmessage-headers"><code>response.writeHead()</code></a>,…
4124 to <a href="#responsewriteheadstatuscode-statusmessage-headers"><code>response.writeHead()</code></…
4125 <pre><code class="language-js"><span class="hljs-comment">// Returns content-type = text/plain</spa…
4131 });</code> <button class="copy-button">copy</button></pre>
4133 will result in a <a href="errors.html#class-typeerror"><code>TypeError</code></a> being thrown.</p>
4136 metrics for each <code>Http2Session</code> and <code>Http2Stream</code> instance.</p>
4137 <pre><code class="language-js"><span class="hljs-keyword">const</span> { <span class="hljs-title cl…
4148 …-attr">entryTypes</span>: [<span class="hljs-string">'http2'</span>] });</code> <button class="cop…
4149 <p>The <code>entryType</code> property of the <code>PerformanceEntry</code> will be equal to <code>…
4150 <p>The <code>name</code> property of the <code>PerformanceEntry</code> will be equal to either
4151 <code>'Http2Stream'</code> or <code>'Http2Session'</code>.</p>
4152 <p>If <code>name</code> is equal to <code>Http2Stream</code>, the <code>PerformanceEntry</code> wil…
4155 …code>bytesRead</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_struct…
4156 <code>Http2Stream</code>.</li>
4157 …code>bytesWritten</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_str…
4158 <code>Http2Stream</code>.</li>
4159 …code>id</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Nu…
4160 <li><code>timeToFirstByte</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/D…
4161 <code>PerformanceEntry</code> <code>startTime</code> and the reception of the first <code>DATA</cod…
4162 <li><code>timeToFirstByteSent</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScri…
4163 the <code>PerformanceEntry</code> <code>startTime</code> and sending of the first <code>DATA</code>…
4164 <li><code>timeToFirstHeader</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript…
4165 <code>PerformanceEntry</code> <code>startTime</code> and the reception of the first header.</li>
4167 <p>If <code>name</code> is equal to <code>Http2Session</code>, the <code>PerformanceEntry</code> wi…
4170 …code>bytesRead</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_struct…
4171 …code>bytesWritten</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_str…
4172 <li><code>framesReceived</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Da…
4173 <code>Http2Session</code>.</li>
4174 …code>framesSent</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_struc…
4175 <li><code>maxConcurrentStreams</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScr…
4176 open during the lifetime of the <code>Http2Session</code>.</li>
4177 <li><code>pingRTT</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_stru…
4178 of a <code>PING</code> frame and the reception of its acknowledgment. Only present if
4179 a <code>PING</code> frame has been sent on the <code>Http2Session</code>.</li>
4180 <li><code>streamAverageDuration</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaSc…
4181 all <code>Http2Stream</code> instances.</li>
4182 …code>streamCount</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_stru…
4183 the <code>Http2Session</code>.</li>
4184 …code>type</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#…
4185 <code>Http2Session</code>.</li>
4187 </section><section><h3>Note on <code>:authority</code> and <code>host</code><span><a class="mark" h…
4188 <p>HTTP/2 requires requests to have either the <code>:authority</code> pseudo-header
4189 or the <code>host</code> header. Prefer <code>:authority</code> when constructing an HTTP/2
4190 request directly, and <code>host</code> when converting from HTTP/1 (in proxies,
4192 <p>The compatibility API falls back to <code>host</code> if <code>:authority</code> is not
4193 present. See <a href="#requestauthority"><code>request.authority</code></a> for more information. H…
4194 if you don't use the compatibility API (or use <code>req.headers</code> directly),