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

Method writeEarlyHints

lib/internal/http2/compat.js:937–961  ·  view source on GitHub ↗
(hints)

Source from the content-addressed store, hash-verified

935 }
936
937 writeEarlyHints(hints) {
938 validateObject(hints, 'hints');
939
940 const headers = { __proto__: null };
941
942 const linkHeaderValue = validateLinkHeaderValue(hints.link);
943
944 for (const key of ObjectKeys(hints)) {
945 if (key !== 'link') {
946 const name = key.trim().toLowerCase();
947 assertValidHeader(name, hints[key]);
948 if (!checkIsHttpToken(name))
949 throw new ERR_INVALID_HTTP_TOKEN('Header name', name);
950 headers[name] = hints[key];
951 }
952 }
953
954 if (linkHeaderValue.length === 0) {
955 return false;
956 }
957
958 headers.Link = linkHeaderValue;
959
960 return this.writeInformation(HTTP_STATUS_EARLY_HINTS, headers);
961 }
962}
963
964function onServerStream(ServerRequest, ServerResponse,

Calls 2

writeInformationMethod · 0.95
checkIsHttpTokenFunction · 0.85

Tested by

no test coverage detected