HTTPリクエストからバイナリのHTTPレスポンスを得たい。
HTTP Request
ノードのデフォルトの動作は、レスポンスボディを文字列として msg.payload
で返します。
ノードの設定の 出力形式
を バイナリバッファ
に変更して、バイナリバッファとして 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":"http://localhost: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をセットするレシピから
HTTP Request
ノードの 出力形式
設定を バイナリバッファ
に変更したものです。
Debug
ノードも、下記のようにpayloadをバイナリバッファで表示します:
[ 80, 75, 3, 4, 20, 0, 6, 0, 8, 0 … ]
Node-RED: Low-code programming for event-driven applications.
Copyright OpenJS Foundation and Node-RED contributors. All rights reserved. The OpenJS Foundation has registered trademarks and uses trademarks. For a list of trademarks of the OpenJS Foundation, please see our Trademark Policy and Trademark List. Trademarks and logos not indicated on the list of OpenJS Foundation trademarks are trademarks™ or registered® trademarks of their respective holders. Use of them does not imply any affiliation with or endorsement by them.
The OpenJS Foundation | Terms of Use | Privacy Policy | OpenJS Foundation Bylaws | Trademark Policy | Trademark List | Cookie Policy