|
6 | 6 |
|
7 | 7 | ### `appendHeader(event, name, value)` |
8 | 8 |
|
| 9 | +Append a response header by name. |
| 10 | + |
9 | 11 | ### `appendHeaders(event, headers)` |
10 | 12 |
|
| 13 | +Append the response headers. |
| 14 | + |
11 | 15 | ### `appendResponseHeader(event, name, value)` |
12 | 16 |
|
| 17 | +Append a response header by name. |
| 18 | + |
13 | 19 | ### `appendResponseHeaders(event, headers)` |
14 | 20 |
|
| 21 | +Append the response headers. |
| 22 | + |
15 | 23 | ### `clearResponseHeaders(event, headerNames?)` |
16 | 24 |
|
17 | 25 | Remove all response headers, or only those specified in the headerNames array. |
18 | 26 |
|
19 | 27 | ### `defaultContentType(event, type?)` |
20 | 28 |
|
| 29 | +Set the response status code and message. |
| 30 | + |
21 | 31 | ### `getResponseHeader(event, name)` |
22 | 32 |
|
| 33 | +Alias for `getResponseHeaders`. |
| 34 | + |
23 | 35 | ### `getResponseHeaders(event)` |
24 | 36 |
|
| 37 | +Get the response headers object. |
| 38 | + |
25 | 39 | ### `getResponseStatus(event)` |
26 | 40 |
|
| 41 | +Get the current response status code. |
| 42 | + |
27 | 43 | ### `getResponseStatusText(event)` |
28 | 44 |
|
| 45 | +Get the current response status message. |
| 46 | + |
29 | 47 | ### `isStream(data)` |
30 | 48 |
|
| 49 | +Checks if the data is a stream. (Node.js Readable Stream, React Pipeable Stream, or Web Stream) |
| 50 | + |
31 | 51 | ### `isWebResponse(data)` |
32 | 52 |
|
| 53 | +Checks if the data is a Response object. |
| 54 | + |
33 | 55 | ### `removeResponseHeader(event, name)` |
34 | 56 |
|
| 57 | +Remove a response header by name. |
| 58 | + |
35 | 59 | ### `send(event, data?, type?)` |
36 | 60 |
|
| 61 | +Directly send a response to the client. |
| 62 | +**Note:** This function should be used only when you want to send a response directly without using the `h3` event. Normaly you can directly `return` a value inside event handlers. |
| 63 | + |
37 | 64 | ### `sendNoContent(event, code?)` |
38 | 65 |
|
39 | | -Respond with an empty payload.<br> Note that calling this function will close the connection and no other data can be sent to the client afterwards. |
| 66 | +Respond with an empty payload.<br> |
| 67 | +Note that calling this function will close the connection and no other data can be sent to the client afterwards. |
40 | 68 |
|
41 | 69 | ### `sendRedirect(event, location, code)` |
42 | 70 |
|
| 71 | +Send a redirect response to the client. |
| 72 | +It adds the `location` header to the response and sets the status code to 302 by default. |
| 73 | +In the body, it sends a simple HTML page with a meta refresh tag to redirect the client in case the headers are ignored. |
| 74 | + |
43 | 75 | ### `sendStream(event, stream)` |
44 | 76 |
|
| 77 | +Send a stream response to the client. |
| 78 | +Note: You can directly `return` a stream value inside event handlers alternatively which is recommended. |
| 79 | + |
45 | 80 | ### `sendWebResponse(event, response)` |
46 | 81 |
|
| 82 | +Send a Response object to the client. |
| 83 | + |
47 | 84 | ### `setHeader(event, name, value)` |
48 | 85 |
|
| 86 | +Set a response header by name. |
| 87 | + |
49 | 88 | ### `setHeaders(event)` |
50 | 89 |
|
| 90 | +Set the response headers. |
| 91 | + |
51 | 92 | ### `setResponseHeader(event, name, value)` |
52 | 93 |
|
| 94 | +Set a response header by name. |
| 95 | + |
53 | 96 | ### `setResponseHeaders(event)` |
54 | 97 |
|
| 98 | +Set the response headers. |
| 99 | + |
55 | 100 | ### `setResponseStatus(event, code?, text?)` |
56 | 101 |
|
| 102 | +Set the response status code and message. |
| 103 | + |
57 | 104 | ### `writeEarlyHints(event, hints, cb)` |
58 | 105 |
|
| 106 | +Write `HTTP/1.1 103 Early Hints` to the client. |
| 107 | + |
59 | 108 | <!-- /automd --> |
0 commit comments