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

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

WBOY
WBOYOriginal
2016-05-16 16:27:112498browse

Method description:

Set header file information.

If the information to be sent already contains a header file, the value of the header file will be overwritten after executing this method.

If a header file needs to pass multiple values, you can use an array.

Grammar:

Copy code The code is as follows:

response.setHeader(name, value)

Receive parameters:

name The type of response header. Note that this name is not case-sensitive.

value The value of the response header

Example:

Copy code The code is as follows:

response.setHeader("Content-Type", "text/html");
//Or use array form
response.setHeader("Set-Cookie", ["type=ninja", "language=javascript"]);
Statement:
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