You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _includes/api/en/4x/res-cookie.md
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,7 @@ The `options` parameter is an object that can have the following properties.
12
12
| `httpOnly` | Boolean | Flags the cookie to be accessible only by the web server.
13
13
| `maxAge` | Number | Convenient option for setting the expiry time relative to the current time in milliseconds.
14
14
| `path` | String | Path for the cookie. Defaults to "/".
15
+
| `priority` | String | Value of the "Priority" **Set-Cookie** attribute.
15
16
| `secure` | Boolean | Marks the cookie to be used with HTTPS only.
16
17
| `signed` | Boolean | Indicates if the cookie should be signed.
17
18
| `sameSite` | Boolean or String | Value of the "SameSite" **Set-Cookie** attribute. More information at [https://tools.ietf.org/html/draft-ietf-httpbis-cookie-same-site-00#section-4.1.1](https://tools.ietf.org/html/draft-ietf-httpbis-cookie-same-site-00#section-4.1.1).
Copy file name to clipboardExpand all lines: _includes/api/en/4x/res-download.md
+12-1Lines changed: 12 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,17 @@
2
2
3
3
Transfers the file at `path` as an "attachment". Typically, browsers will prompt the user for download.
4
4
By default, the `Content-Disposition` header "filename=" parameter is derrived from the `path` argument, but can be overridden with the `filename` parameter.
5
-
If `path` is relative, then it will be based on the current working directory of the process.
5
+
If `path` is relative, then it will be based on the current working directory of the process or
6
+
the `root` option, if provided.
7
+
8
+
<divclass="doc-box doc-warn"markdown="1">
9
+
This API provides access to data on the running file system. Ensure that either (a) the way in
10
+
which the `path` argument was constructed is secure if it contains user input or (b) set the `root`
11
+
option to the absolute path of a directory to contain access within.
12
+
13
+
When the `root` option is provided, Express will validate that the relative path provided as
14
+
`path` will resolve within the given `root` option.
15
+
</div>
6
16
7
17
The following table provides details on the `options` parameter.
8
18
@@ -15,6 +25,7 @@ The optional `options` argument is supported by Express v4.16.0 onwards.
|`maxAge`| Sets the max-age property of the `Cache-Control` header in milliseconds or a string in [ms format](https://www.npmjs.org/package/ms)| 0 | 4.16+ |
28
+
|`root`| Root directory for relative filenames.|| 4.18+ |
18
29
|`lastModified`| Sets the `Last-Modified` header to the last modified date of the file on the OS. Set `false` to disable it.| Enabled | 4.16+ |
19
30
|`headers`| Object containing HTTP headers to serve with the file. The header `Content-Disposition` will be overriden by the `filename` argument.|| 4.16+ |
20
31
|`dotfiles`| Option for serving dotfiles. Possible values are "allow", "deny", "ignore".| "ignore" | 4.16+ |
The 4.18.0 minor release includes bug fixes and some new features, including:
15
+
16
+
<ul>
17
+
<limarkdown="1"class="changelog-item">
18
+
The [`app.get()` method](/{{ page.lang }}/4x/api.html#app.get) and the [`app.set()` method](/{{ page.lang }}/4x/api.html#app.set) now ignores properties directly on `Object.prototype` when getting a setting value.
19
+
</li>
20
+
21
+
<limarkdown="1"class="changelog-item">
22
+
The [`res.cookie()` method](/{{ page.lang }}/4x/api.html#res.cookie) now accepts a "priority" option to set the Priority attribute on the Set-Cookie response header.
23
+
</li>
24
+
25
+
<limarkdown="1"class="changelog-item">
26
+
The [`res.cookie()` method](/{{ page.lang }}/4x/api.html#res.cookie) now rejects an Invalid Date object provided as the "expires" option.
27
+
</li>
28
+
29
+
<limarkdown="1"class="changelog-item">
30
+
The [`res.cookie()` method](/{{ page.lang }}/4x/api.html#res.cookie) now works when `null` or `undefined` is explicitly provided as the "maxAge" argument.
31
+
</li>
32
+
33
+
<limarkdown="1"class="changelog-item">
34
+
Starting with this version, Express supports Node.js 18.x.
35
+
</li>
36
+
37
+
<limarkdown="1"class="changelog-item">
38
+
The [`res.download()` method](/{{ page.lang }}/4x/api.html#res.download) now accepts a "root" option to match [`res.sendFile()`](/{{ page.lang }}/4x/api.html#res.sendFile).
39
+
</li>
40
+
41
+
<limarkdown="1"class="changelog-item">
42
+
The [`res.download()` method](/{{ page.lang }}/4x/api.html#res.download) can be supplied with an `options` object without providing a `filename` argument, simplifying calls when the default `filename` is desired.
43
+
</li>
44
+
45
+
<limarkdown="1"class="changelog-item">
46
+
The [`res.format()` method](/{{ page.lang }}/4x/api.html#res.format) now invokes the provided "default" handler with the same arguments as the type handlers (`req`, `res`, and `next`).
47
+
</li>
48
+
49
+
<limarkdown="1"class="changelog-item">
50
+
The [`res.send()` method](/{{ page.lang }}/4x/api.html#res.send) will not attempt to send a response body when the response code is set to 205.
51
+
</li>
52
+
53
+
<limarkdown="1"class="changelog-item">
54
+
The default error handler will now remove certain response headers that will break the error response rendering, if they were set previously.
55
+
</li>
56
+
57
+
<limarkdown="1"class="changelog-item">
58
+
The status code 425 is now represented as the standard "Too Early" instead of "Unordered Collection".
59
+
</li>
60
+
</ul>
61
+
62
+
For a complete list of changes in this release, see [History.md](https://github.com/expressjs/express/blob/master/History.md#4180--2022-04-25).
0 commit comments