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

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

问题描述

我知道 chrome.webRequest.onBeforeRequest 允许拦截,分析和阻止请求,但它只允许访问请求头,而不是请求机构(据我所知)。



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

看起来有一个API更改提议这里暗示这一点。



有没有另一种方法可以完成?



感谢。

解决方案

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



为了访问主体,您需要执行以下操作:

  chrome.webRequest.onBeforeRequest.addListener(
函数(详情)
{
console.log(details.requestBody);
},
{url:[https://myurlhere.com/*]},
['requestBody']
);


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.

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

Is there another way this could be accomplished?

Thanks.

解决方案

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天全站免登陆