Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5fbccae

Browse filesBrowse files
meyfaRafaelGSS
authored andcommitted
doc: fix http and http2 writeEarlyHints() parameter
Both http and http2 `response.writeEarlyHints()` take an object, not an array, as their first parameter. For http, this was updated in the examples via #44820 except for the final example, which this patch fixes. The doc for the http2 version was not touched in #44820 although I am pretty sure from skimming the code that it behaves identically to http, and so propose to change its doc as well. Finally, some bogus headline levels are fixed in http2 docs. PR-URL: #45000 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
1 parent a27c994 commit 5fbccae
Copy full SHA for 5fbccae

File tree

Expand file treeCollapse file tree

2 files changed

+14
-8
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+14
-8
lines changed
Open diff view settings
Collapse file

‎doc/api/http.md‎

Copy file name to clipboardExpand all lines: doc/api/http.md
+3-1Lines changed: 3 additions & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -2175,7 +2175,9 @@ response.writeEarlyHints({
21752175
});
21762176

21772177
const earlyHintsCallback = () => console.log('early hints message sent');
2178-
response.writeEarlyHints(earlyHintsLinks, earlyHintsCallback);
2178+
response.writeEarlyHints({
2179+
'link': earlyHintsLinks,
2180+
}, earlyHintsCallback);
21792181
```
21802182

21812183
### `response.writeHead(statusCode[, statusMessage][, headers])`
Collapse file

‎doc/api/http2.md‎

Copy file name to clipboardExpand all lines: doc/api/http2.md
+11-7Lines changed: 11 additions & 7 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -3787,7 +3787,7 @@ Removes a header that has been queued for implicit sending.
37873787
response.removeHeader('Content-Encoding');
37883788
```
37893789

3790-
### `response.req`
3790+
#### `response.req`
37913791

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

4008-
### `response.writeEarlyHints(links)`
4008+
#### `response.writeEarlyHints(hints)`
40094009

40104010
<!-- YAML
40114011
added: v18.11.0
40124012
-->
40134013

4014-
* `links` {string|Array}
4014+
* `hints` {Object}
40154015

40164016
Sends a status `103 Early Hints` to the client with a Link header,
40174017
indicating that the user agent can preload/preconnect the linked resources.
4018-
The `links` can be a string or an array of strings containing the values
4019-
of the `Link` header.
4018+
The `hints` is an object containing the values of headers to be sent with
4019+
early hints message.
40204020

40214021
**Example**
40224022

40234023
```js
40244024
const earlyHintsLink = '</styles.css>; rel=preload; as=style';
4025-
response.writeEarlyHints(earlyHintsLink);
4025+
response.writeEarlyHints({
4026+
'link': earlyHintsLink,
4027+
});
40264028

40274029
const earlyHintsLinks = [
40284030
'</styles.css>; rel=preload; as=style',
40294031
'</scripts.js>; rel=preload; as=script',
40304032
];
4031-
response.writeEarlyHints(earlyHintsLinks);
4033+
response.writeEarlyHints({
4034+
'link': earlyHintsLinks,
4035+
});
40324036
```
40334037

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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.