diff --git a/doc/api/http.md b/doc/api/http.md index 9144f8aec7f3bf..3675329d0cbbe6 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -2162,7 +2162,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 0964c91e4e0f60..d7af2b47f237f4 100644 --- a/doc/api/http2.md +++ b/doc/api/http2.md @@ -3773,7 +3773,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])`