diff --git a/doc/api/http.md b/doc/api/http.md index cd658f856b9aba..431330ee273dea 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -2127,10 +2127,41 @@ buffer. Returns `false` if all or part of the data was queued in user memory. added: v0.3.0 --> -Sends a HTTP/1.1 100 Continue message to the client, indicating that +Sends an HTTP/1.1 100 Continue message to the client, indicating that the request body should be sent. See the [`'checkContinue'`][] event on `Server`. +### `response.writeEarlyHints(links[, callback])` + + + +* `links` {string|Array} +* `callback` {Function} + +Sends an HTTP/1.1 103 Early Hints message 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 optional `callback` argument will be called when +the response message has been written. + +**Example** + +```js +const earlyHintsLink = '; rel=preload; as=style'; +response.writeEarlyHints(earlyHintsLink); + +const earlyHintsLinks = [ + '; rel=preload; as=style', + '; rel=preload; as=script', +]; +response.writeEarlyHints(earlyHintsLinks); + +const earlyHintsCallback = () => console.log('early hints message sent'); +response.writeEarlyHints(earlyHintsLinks, earlyHintsCallback); +``` + ### `response.writeHead(statusCode[, statusMessage][, headers])` + +* `links` {string|Array} + +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. + +**Example** + +```js +const earlyHintsLink = '; rel=preload; as=style'; +response.writeEarlyHints(earlyHintsLink); + +const earlyHintsLinks = [ + '; rel=preload; as=style', + '; rel=preload; as=script', +]; +response.writeEarlyHints(earlyHintsLinks); +``` + #### `response.writeHead(statusCode[, statusMessage][, headers])`