拦截来自 chrome 扩展的 HTTP 请求正文 [英] Intercept HTTP request body from chrome extension

查看:40
本文介绍了拦截来自 chrome 扩展的 HTTP 请求正文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道 chrome.webRequest.onBeforeRequest 允许拦截、分析和阻止请求,但它只允许访问请求标头,而不允许访问请求正文(就我知道).

I'm aware that chrome.webRequest.onBeforeRequest allows a request to be intercepted, analyzed and blocked, but it only allows access to the request headers, and not the request body (as far as i know).

示例用例:想想拦截表单值.

Sample use case: think intercepting form values.

似乎有一个 API 更改提案 此处 正是暗示这一点.

It seems there is a API change proposal here suggesting exactly this.

还有其他方法可以实现吗?

Is there another way this could be accomplished?

谢谢.

推荐答案

此功能现已添加到 API 中,请参阅 文档.

This functionality has been added to the API now, see the documentation.

为了访问正文,您需要执行以下操作:

In order to access the body you need to do the following:

chrome.webRequest.onBeforeRequest.addListener(
    function(details)
    {
        console.log(details.requestBody);
    },
    {urls: ["https://myurlhere.com/*"]},
    ['requestBody']
);

这篇关于拦截来自 chrome 扩展的 HTTP 请求正文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆