diff --git a/doc/api/http.md b/doc/api/http.md index cf5b12a13722f1..d3852992522683 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -2175,7 +2175,9 @@ response.writeEarlyHints({ }); const earlyHintsCallback = () => console.log('early hints message sent'); -response.writeEarlyHints(earlyHintsLinks, earlyHintsCallback); +response.writeEarlyHints({ + 'link': earlyHintsLinks, +}, earlyHintsCallback); ``` ### `response.writeHead(statusCode[, statusMessage][, headers])` diff --git a/doc/api/http2.md b/doc/api/http2.md index 0759c84965f6af..713edfca66376e 100644 --- a/doc/api/http2.md +++ b/doc/api/http2.md @@ -3787,7 +3787,7 @@ Removes a header that has been queued for implicit sending. response.removeHeader('Content-Encoding'); ``` -### `response.req` +#### `response.req` -* `links` {string|Array} +* `hints` {Object} Sends a status `103 Early Hints` to the client with a Link header, indicating that the user agent can preload/preconnect the linked resources. -The `links` can be a string or an array of strings containing the values -of the `Link` header. +The `hints` is an object containing the values of headers to be sent with +early hints message. **Example** ```js const earlyHintsLink = '; rel=preload; as=style'; -response.writeEarlyHints(earlyHintsLink); +response.writeEarlyHints({ + 'link': earlyHintsLink, +}); const earlyHintsLinks = [ '; rel=preload; as=style', '; rel=preload; as=script', ]; -response.writeEarlyHints(earlyHintsLinks); +response.writeEarlyHints({ + 'link': earlyHintsLinks, +}); ``` #### `response.writeHead(statusCode[, statusMessage][, headers])`