Home > Web Front-end > JS Tutorial > Instructions for using the http.response.end method in node.js_node.js

Instructions for using the http.response.end method in node.js_node.js

WBOY
Release: 2016-05-16 16:27:09
Original
1672 people have browsed it

Method description:

End response, telling the client that all messages have been sent. This function must be called once when all content to be returned has been sent.

If this function is not called, the client will be in a waiting state forever.

Grammar:

Copy code The code is as follows:

response.end([data], [encoding])

Receive parameters:

data The characters to be output after end() is executed. If the value of data is specified, it means that after response.end() is executed, a response.write(data, encoding);

encoding The character encoding corresponding to data

Example:

Copy code The code is as follows:

var http = require('http');
http.createServer(function(req, res){
res.writeHead(200, {'Content-type' : 'text/html'});
res.write('

Node.js

');
res.end('

Hello World

');
}).listen(3000);
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template