node-red/packages/node_modules/@node-red/nodes/locales/zh-CN/network/21-httpin.html

82 lines
4.6 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!--
Copyright JS Foundation and other contributors, http://js.foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<script type="text/x-red" data-help-name="http in">
<p>创建用于创建Web服务的HTTP端点</p>
<h3>输出</h3>
<dl class="message-properties">
<dt>payload</dt>
<dd>GET请求包含任何查询字符串参数的对象或者包含HTTP请求正文</dd>
<dt>req<span class="property-type">object</span></dt>
<dd>HTTP请求对象该对象包含有关请求信息的多个属性
<ul>
<li><code>body</code> - </li>
<li><code>headers</code> - HTTP</li>
<li><code>query</code> - </li>
<li><code>params</code> - </li>
<li><code>cookies</code> - cookie</li>
<li><code>files</code> - </li>
</ul>
</dd>
<dt>res<span class="property-type">object</span></dt>
<dd>HTTP响应对象此属性不应直接使用<code>HTTP Response</code></dd>
</dl>
<h3>详细</h3>
<p>节点将在配置的路径上监听特定类型的请求路径可以完全指定例如<code>/user</code><code>/user/:name</code> 使<code>msg.req.params</code>访</p>
<p>对于包含正文的请求例如POST或PUT请求的内容将作为<code>msg.payload</code></p>
<p>如果可以确定请求的内容类型则正文将被解析为任何适当的类型例如<code>application/json</code>JavaScript</p>
<p><b>注意</b>HTTP</p>
</script>
<script type="text/x-red" data-help-name="http response">
<p>将响应发送回从HTTP输入节点接收的请求</p>
<h3>输入</h3>
<dl class="message-properties">
<dt>payload <span class="property-type">string</span></dt>
<dd>响应的正文</dd>
<dt class="optional">statusCode <span class="property-type">数值</span></dt>
<dd>如果设置则用作响应状态代码默认值200</dd>
<dt class="optional">headers <span class="property-type">object</span></dt>
<dd>如果设置则提供HTTP头以包含在响应中</dd>
<dt class="optional">cookies <span class="property-type">object</span></dt>
<dd>如果设置则可用于设置或删除cookie</dd>
</dl>
<h3>详细</h3>
<p>还可以在节点本身内设置<code>statusCode</code><code>headers</code>message</p>
<h4>Cookie处理</h4>
<p><code>cookies</code>/使cookieoptions<p>
<p>下面的示例设置两个cookie-一个名为<code>name</code><code>nick</code><code>session</code><code>1234</code>15</p>
<pre>
msg.cookies = {
name: 'nick',
session: {
value: '1234',
maxAge: 900000
}
}</pre>
<p>有效选项包括</p>
<ul>
<li><code>domain</code> - () Cookie</li>
<li><code>expires</code> - () GMT0cookie</li>
<li><code>maxAge</code> - () </li>
<li><code>path</code> - (字符串) Cookie的路径。默认为/</li>
<li><code>value</code> - () Cookie使</li>
</ul>
<p>要删除Cookie请将其<code>value</code><code>null</code></p>
</script>