Http. response. end method in node. js instructions for use _ node. js

Source: Internet
Author: User
This article mainly introduces node. http. response. end method usage instructions. This article introduces http. response. end method description, syntax, receive parameters, use instances, and implement Source Code. For more information, see Method description:

End the response and tell the client that all messages have been sent. When all the content to be returned is sent, the function must be called once.

If you do not call this function, the client will always be in the waiting state.

Syntax:

The Code is as follows:


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

Receiving parameters:

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

Character encoding of data corresponding to encoding

Example:

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 Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.