Node favicon. Icon request

Source: Internet
Author: User
1 var HTTP = require ("HTTP"); 2 var Server = http. createserver (); 3 server. on ("request", function (req, Res) {5 console. log (req. URL); 6 res. end (); 7}); 8 server. listen (1337, "127.0.0.1 ");

Such code will have two requests during the request:

In the first example, the URL address is the target URL of the client request entered by the user. "/" indicates that the target URL address is the root directory of the Web application.

The second target URL address is the display icon of the page in the favorites folder. The default value is favicon. ico. The target URL address of the automatically sent request.

You can modify the preceding code to block such requests.

1 var HTTP = require ("HTTP"); 2 var Server = http. createserver (); 3 server. on ("request", function (req, Res) {4 If (req. URL! = "/Favicon. ICO ") 5 console. log (req. URL); 6 res. end (); 7}); 8 server. listen (1337, "127.0.0.1 ");

 

Node favicon. Icon request

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.