拦截来自chrome扩展的HTTP请求体

编程入门 行业动态 更新时间:2024-10-18 12:23:35
本文介绍了拦截来自chrome扩展的HTTP请求体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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

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

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

感谢。

解决方案

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

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

chrome.webRequest.onBeforeRequest.addListener(函数(详情) { console.log(details.requestBody); }, {url:[myurlhere/*]}, ['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: ["myurlhere/*"]}, ['requestBody'] );

更多推荐

拦截来自chrome扩展的HTTP请求体

本文发布于:2023-11-28 09:57:22,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:chrome   HTTP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!