• V
 

获取二进制响应

问题

您想从 HTTP 请求中获取二进制 HTTP 响应。

解决方案

HTTP Request 节点默认会将响应体作为字符串返回到 msg.payload 中。将此节点的 Return 配置更改为 a binary buffer,以将响应作为二进制缓冲区返回到 msg.payload 中。

示例

[{"id":"871ee927.0d69c8","type":"inject","z":"c9a81b70.8abed8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":240,"y":660,"wires":[["8ea4e52a.03d678"]]},{"id":"8ea4e52a.03d678","type":"http request","z":"c9a81b70.8abed8","name":"binary http request","method":"GET","ret":"bin","url":"https://:1880/binary","tls":"","x":410,"y":660,"wires":[["70309d0c.4dc504"]]},{"id":"70309d0c.4dc504","type":"debug","z":"c9a81b70.8abed8","name":"","active":true,"console":"false","complete":"false","x":590,"y":660,"wires":[]}]

我们修改了 设置请求 URL 的 URL 配方 中的流程,将 HTTP Request 节点的 Return 配置更改为 a binary bufferDebug 节点会将有效负载显示为二进制缓冲区,例如

[ 80, 75, 3, 4, 20, 0, 6, 0, 8, 0 … ]