MCPcopy Index your code
hub / github.com/nodejs/node / additionalHeaders

Method additionalHeaders

lib/internal/http2/core.js:3193–3228  ·  view source on GitHub ↗
(headers)

Source from the content-addressed store, hash-verified

3191 // a 1xx informational code and it MUST be sent before the request/response
3192 // headers are sent, or an error will be thrown.
3193 additionalHeaders(headers) {
3194 if (this.destroyed || this.closed)
3195 throw new ERR_HTTP2_INVALID_STREAM();
3196 if (this.headersSent)
3197 throw new ERR_HTTP2_HEADERS_AFTER_RESPOND();
3198
3199 assertIsObject(headers, 'headers');
3200 headers = ObjectAssign({ __proto__: null }, headers);
3201
3202 debugStreamObj(this, 'sending additional headers');
3203
3204 if (headers[HTTP2_HEADER_STATUS] != null) {
3205 const statusCode = headers[HTTP2_HEADER_STATUS] |= 0;
3206 if (statusCode === HTTP_STATUS_SWITCHING_PROTOCOLS)
3207 throw new ERR_HTTP2_STATUS_101();
3208 if (statusCode < 100 || statusCode >= 200) {
3209 throw new ERR_HTTP2_INVALID_INFO_STATUS(headers[HTTP2_HEADER_STATUS]);
3210 }
3211 }
3212
3213 this[kUpdateTimer]();
3214
3215 const headersList = buildNgHeaderString(
3216 headers,
3217 assertValidPseudoHeaderResponse,
3218 this.session[kStrictSingleValueFields],
3219 );
3220 if (!this[kInfoHeaders])
3221 this[kInfoHeaders] = [headers];
3222 else
3223 this[kInfoHeaders].push(headers);
3224
3225 const ret = this[kHandle].info(headersList);
3226 if (ret < 0)
3227 this.destroy(new NghttpError(ret));
3228 }
3229}
3230
3231ServerHttp2Stream.prototype[kProceed] = ServerHttp2Stream.prototype.respond;

Calls 6

ObjectAssignFunction · 0.85
debugStreamObjFunction · 0.85
buildNgHeaderStringFunction · 0.85
infoMethod · 0.80
pushMethod · 0.45
destroyMethod · 0.45

Tested by

no test coverage detected