简体   繁体   English

response.writeHead()方法中的{'Content-Type:':'text / plain'}的数据类型是什么?

[英]what is data type of {'Content-Type:':'text/plain'} in response.writeHead() method?

The common way to creating web server in node.js is something like this: response.writeHead(200,{'Content-Type':'text/plain'}); 在node.js中创建Web服务器的常用方法如下: response.writeHead(200,{'Content-Type':'text/plain'}); ,but what is data type of {'Content-Type:':'text/plain'} section? ,但是{'Content-Type:':'text/plain'}部分的数据类型是什么? an Object ? 一个Object or a tuple ? 还是tuple I have never seen anything like that before in Javascript. 我以前从未在Javascript中看到过类似的东西。

It is an anonymous object. 它是一个匿名对象。 Have you seen something simple like this: 您是否看到过类似以下的简单内容:

{x: 10}

Well it is the same thing except it has a '-' in the key name so the key has to be put in quotes. 好吧,除了密钥名称中带有“-”以外,它是一回事,因此必须将密钥置于引号中。 The object is using specific naming that corresponds with the standards for HTTP headers ( ref ). 该对象正在使用与HTTP标头( ref )的标准相对应的特定命名。

Text/plain is full text like .txt file. 文字/纯文字是.txt文件之类的全文。

In text/plain content, the HTML doesn't be parsed. 在文本/纯文本内容中,不会解析HTML。 If you write " <b>Hi</b> ", you will see the same thing (" <b>Hi</b> "). 如果您输入“ <b>Hi</b> ”,则会看到相同的内容(“ <b>Hi</b> ”)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如果省略response.writeHead()怎么办 - what if you omit response.writeHead() response.writeHead上的意外令牌 - Unexpected token on response.writeHead Google Drive API 响应中不需要的“content-type: text/plain;charset=UTF-8” header - Unwanted “content-type: text/plain;charset=UTF-8” header in Google Drive API Response 依赖Content-Type:text / plain来缓解恶意javascript执行是否安全? - Is it safe to rely on Content-Type: text/plain to mitigate malicious javascript execution in response? 在文本文件中保存响应类型“ Content-Type:text / javascript” - Save response type “Content-Type : text/javascript” in text file 使用 CDK 在 API 网关方法响应中指定 content-type - Specify content-type in API Gateway method response using CDK 尽管有text / javascript内容类型,但仍未执行rails 3 javascript - rails 3 javascript not executed despite a text/javascript content-type in response response.setHeader 和 response.writeHead 的区别? - Difference between response.setHeader and response.writeHead? response.status 和 response.writeHead 的区别? - Difference between response.status and response.writeHead? 为什么 header 中的内容类型仍然是 text/plain 虽然我将其设置为 application/json - Why content-type in header remains text/plain though I set it as application/json
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM