google-chrome-extension - Chrome.webRequest.onBeforeRequest - 在 POST 上传文件,但 requestBody.raw 为空
问题描述
在上传文件和表单数据时,我正在尝试使用 chrome 扩展来获取 POST 请求的正文。
使用以下代码块:
/// background.js ///
chrome.webRequest.onBeforeRequest.addListener(
// callback
function (details) {
if (details.requestBody.raw) {
for (let i = 0; i < details.requestBody.raw.length; i++) {
var postedString = decodeURIComponent(String.fromCharCode.apply(null, new Uint8Array(details.requestBody.raw[i].bytes)));
console.log(postedString)
}
}
return { cancel: false }
},
{
urls: ["https://*/*", "http://*/*"]
},
["blocking", "requestBody"]
);
但是,我无法从控制台看到上传文件的内容文本(但我只能看到表单数据,message=Hello)。
------WebKitFormBoundaryINmsBoKGn0M78aYv
Content-Disposition: form-data; name="message"
Hello
------WebKitFormBoundaryINmsBoKGn0M78aYv
Content-Disposition: form-data; name="file"; filename="test.txt"
Content-Type: text/plain
manufest.json 是下面的代码块。
{
"name": "testo_plugin",
"description": "Build an test_plugin!",
"version": "1.0.0",
"manifest_version": 2,
"background": {
"page": "background.html"
},
"permissions": [
"storage",
"webRequest",
"webRequestBlocking",
"https://*/*",
"http://*/*"
]
}
我的语法有问题吗?或者它是 Chrome 的规范?(我找不到这个规范)
Chrome版本:91.0.4472.114(正式版)(64位)
解决方案
推荐阅读
- c# - 会话变量立即为空..ASP.net Core
- suitecrm - 如何在 SuiteCRM 中获取链接 bean 功能
- bash - 在循环中运行 gnome-terminal 不会阻止等待程序完成
- reactjs - React 不适用于 Traefik 中的路径和前缀
- c - system() 函数字符串长度限制
- mysql - Laravel 数组到多条记录的字符串转换
- validation - 使用单元格内容修改下拉菜单列表
- dart - Flutter:在 pubspec.yaml 文件中添加仅适用于 iOS 的插件
- python - 如何处理熊猫中仅包含 NaN 值的单元格?
- javascript - TopoJson 地图不在 react-simple-map 模块中呈现