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
Sends a response header to the request. The status code is a 3-digit HTTP
2493
2495
status code, like `404`. The last argument, `headers`, are the response headers.
2494
-
For compatibility with [HTTP/1](), one can give a human-readable `statusMessage` as the second argument, which will be silenty ignored and emit a warning.
2496
+
2497
+
For compatibility with [HTTP/1](), a human-readable `statusMessage` may be
2498
+
passed as the second argument. However, because the `statusMessage` has no
2499
+
meaning within HTTP/2, the argument will have no effect and a process warning
2500
+
will be emitted.
2495
2501
2496
2502
Example:
2497
2503
@@ -2502,15 +2508,22 @@ response.writeHead(200, {
2502
2508
'Content-Type':'text/plain' });
2503
2509
```
2504
2510
2505
-
This method must only be called once on a message and it must
2506
-
be called before [`response.end()`][] is called.
2511
+
Note that Content-Length is given in bytes not characters. The
2512
+
`Buffer.byteLength()` API may be used to determine the number of bytes in a
2513
+
given encoding. On outbound messages, Node.js does not check if Content-Length
2514
+
and the length of the body being transmitted are equal or not. However, when
2515
+
receiving messages, Node.js will automatically reject messages when the
2516
+
Content-Length does not match the actual payload size.
2517
+
2518
+
This method may be called at most one time on a message before
2519
+
[`response.end()`][] is called.
2507
2520
2508
2521
If [`response.write()`][] or [`response.end()`][] are called before calling
2509
2522
this, the implicit/mutable headers will be calculated and call this function.
2510
2523
2511
-
When headers have been set with [`response.setHeader()`][], they will be merged with
2512
-
any headers passed to [`response.writeHead()`][], with the headers passed to
2513
-
[`response.writeHead()`][] given precedence.
2524
+
When headers have been set with [`response.setHeader()`][], they will be merged
2525
+
with any headers passed to [`response.writeHead()`][], with the headers passed
0 commit comments