如何使用 nsIWebBrowserPersist 发布数据?
我需要使用 nsIWebBrowserPersist
用法下载文件 (saveURI
)。但该文件应以 POST 方式请求。怎么做呢?
I need to download the file (saveURI
) with nsIWebBrowserPersist
usage. But the file should be requested as POST. How to do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
nsIWebBrowserPersist.saveURI()
采用aPostData
参数 - 如果您传递输入流,则会发出 POST 请求。如果您要发送一些简单的数据,则应使用 nsIStringInputStream最简单的,像这样:nsIWebBrowserPersist.saveURI()
takes anaPostData
parameter - if you pass an input stream there a POST request will made. If you are sending some simple data, using nsIStringInputStream should be easiest, something like this:这是工作代码(感谢 IRC #extdev 的 BenB):
https://developer. mozilla.org/en/Code_snippets/Post_data_to_window#Preprocessing_POST_data
Here is the working code (thanks to BenB from IRC #extdev):
https://developer.mozilla.org/en/Code_snippets/Post_data_to_window#Preprocessing_POST_data