如何在 NSIS 脚本中使用 inetc::post 发出带有标头的 POST 请求

问题描述 投票:0回答:1

当用户使用 NSIS 脚本安装/卸载程序时,我需要进行 POST API 调用,但我不知道如何使用由 AppId 和 AppKey 两个键组成的标头来实现此目的。这是我的脚本代码:

inetc::post "" "http://localhost:3000/api/uninstallations"

此链接https://nsis.sourceforge.io/Inetc_plug-in指示我可以添加像 \HEADER "header: value" 这样的标头,但我需要向标头添加两个键值对。有办法解决这个问题吗?

nsis
1个回答
0
投票

标头字符串原封不动地传递到 WinINet,只需在每个之间添加 CR/LF 对:

Section 
#https://www.whatismybrowser.com/detect/what-http-headers-is-my-browser-sending?sort=dont-sort
InitPluginsDir
inetc::get /header 'AppId: Acme App$\r$\nAppKey: 1234' "https://myhttpheader.com/" "$pluginsdir\tmp.htm" /END
Pop $1
DetailPrint $1
ExecShell "" "$pluginsdir\tmp.htm"
SectionEnd
© www.soinside.com 2019 - 2024. All rights reserved.