Skip to content

Commit 1d26e3d

Browse files
Fix 5.x docs drift from 4.x conventions (part of gh-1881)
- res.type() example had a stray trailing colon and missing quotes (image/png: -> 'image/png'), matching every sibling example in that block and the 4.x doc. - Reordered req.host/req.hostname to match 4.x's order (hostname then host); only moved the blocks, didn't touch their content. - Frontmatter description wording changed from "The request/response object..." to "The req/res object..." to match 4.x.
1 parent b9d5106 commit 1d26e3d

2 files changed

Lines changed: 17 additions & 17 deletions

File tree

src/content/api/5x/api/request/index.mdx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Request Object
3-
description: The request object represents the HTTP request and has properties for the request query string, parameters, body, HTTP headers, and so on
3+
description: The req object represents the HTTP request and has properties for the request query string, parameters, body, HTTP headers, and so on
44
---
55

66
import Alert from '@components/primitives/Alert/Alert.astro';
@@ -234,13 +234,13 @@ console.dir(req.fresh);
234234
// => true
235235
```
236236

237-
### req.host
237+
### req.hostname
238238

239239
<Signature type="String" />
240240

241-
Contains the host derived from the `Host` HTTP header.
241+
Contains the hostname derived from the `Host` HTTP header.
242242

243-
When the [`trust proxy` setting](/api/application/#application-settings)
243+
When the [`trust proxy` setting](/api/application/#options-for-trust-proxy-setting)
244244
does not evaluate to `false`, this property will instead get the value
245245
from the `X-Forwarded-Host` header field. This header can be set by
246246
the client or by the proxy.
@@ -251,21 +251,17 @@ comma-separated values, in which the first value is used.
251251

252252
```js
253253
// Host: "example.com:3000"
254-
console.dir(req.host);
255-
// => 'example.com:3000'
256-
257-
// Host: "[::1]:3000"
258-
console.dir(req.host);
259-
// => '[::1]:3000'
254+
console.dir(req.hostname);
255+
// => 'example.com'
260256
```
261257

262-
### req.hostname
258+
### req.host
263259

264260
<Signature type="String" />
265261

266-
Contains the hostname derived from the `Host` HTTP header.
262+
Contains the host derived from the `Host` HTTP header.
267263

268-
When the [`trust proxy` setting](/api/application/#options-for-trust-proxy-setting)
264+
When the [`trust proxy` setting](/api/application/#application-settings)
269265
does not evaluate to `false`, this property will instead get the value
270266
from the `X-Forwarded-Host` header field. This header can be set by
271267
the client or by the proxy.
@@ -276,8 +272,12 @@ comma-separated values, in which the first value is used.
276272

277273
```js
278274
// Host: "example.com:3000"
279-
console.dir(req.hostname);
280-
// => 'example.com'
275+
console.dir(req.host);
276+
// => 'example.com:3000'
277+
278+
// Host: "[::1]:3000"
279+
console.dir(req.host);
280+
// => '[::1]:3000'
281281
```
282282

283283
### req.ip

src/content/api/5x/api/response/index.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Response
3-
description: The response object represents the HTTP response that an Express app sends when it gets an HTTP request.
3+
description: The res object represents the HTTP response that an Express app sends when it gets an HTTP request.
44
---
55

66
import Alert from '@components/primitives/Alert/Alert.astro';
@@ -1104,7 +1104,7 @@ res.type('.html'); // => 'text/html'
11041104
res.type('html'); // => 'text/html'
11051105
res.type('json'); // => 'application/json'
11061106
res.type('application/json'); // => 'application/json'
1107-
res.type('png'); // => image/png:
1107+
res.type('png'); // => 'image/png'
11081108
```
11091109

11101110
Aliased as `res.contentType(type)`.

0 commit comments

Comments
 (0)