Method description:
Send a response header to the requesting client.
This function can only be called once at most in a request. If it is not called, a response header will be automatically generated.
grammar:
The code copy is as follows:
response.writeHead(statusCode, [reasonPhrase], [headers])
Receive parameters:
statusCode HTTP status code, such as 200 (request successful), 404 (not found), etc.
reasonPhrase
headers is an object similar to an associative array, representing each property of the response header
example:
The code copy is as follows:
var body = 'hello world';
response.writeHead(200, {
'Content-Length': body.length,
'Content-Type': 'text/plain'
});