Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: fix http and http2 writeEarlyHints() parameter #45000

Merged
merged 1 commit into from Oct 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion doc/api/http.md
Expand Up @@ -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])`
Expand Down
18 changes: 11 additions & 7 deletions doc/api/http2.md
Expand Up @@ -3787,7 +3787,7 @@ Removes a header that has been queued for implicit sending.
response.removeHeader('Content-Encoding');
```

### `response.req`
#### `response.req`

<!-- YAML
added: v15.7.0
Expand Down Expand Up @@ -4005,30 +4005,34 @@ Sends a status `100 Continue` to the client, indicating that the request body
should be sent. See the [`'checkContinue'`][] event on `Http2Server` and
`Http2SecureServer`.

### `response.writeEarlyHints(links)`
#### `response.writeEarlyHints(hints)`

<!-- YAML
added: v18.11.0
-->

* `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 = '</styles.css>; rel=preload; as=style';
response.writeEarlyHints(earlyHintsLink);
response.writeEarlyHints({
'link': earlyHintsLink,
});

const earlyHintsLinks = [
'</styles.css>; rel=preload; as=style',
'</scripts.js>; rel=preload; as=script',
];
response.writeEarlyHints(earlyHintsLinks);
response.writeEarlyHints({
'link': earlyHintsLinks,
});
```

#### `response.writeHead(statusCode[, statusMessage][, headers])`
Expand Down