简体   繁体   English

Chrome扩展程序-在onBeforeRequest中获取Content-Type

[英]Chrome extension - getting Content-Type in onBeforeRequest

In a chrome extension I need to know what is the Content-Type of the request in onBeforeRequest callback, because if the Content-Type is application/x-www-form-urlencoded I want to decode the data in requestBody . 在chrome扩展程序中,我需要知道onBeforeRequest回调中请求的Content-Type是什么,因为如果Content-Type是application/x-www-form-urlencoded我想对requestBody的数据进行解码。 however according to the life cycle documentation ( https://developer.chrome.com/extensions/webRequest ) the http headers are not yet available during onBeforeRequest , so I don't know what is the Content-Type. 但是,根据生命周期文档( https://developer.chrome.com/extensions/webRequest),http头在onBeforeRequest期间尚不可用,因此我不知道什么是Content-Type。 is there a way to know if the data is url-encoded during onBeforeRequest ? 有没有办法知道在onBeforeRequest期间数据是否经过url编码?

This is not possible at the time you desire. 在您想要的时候这是不可能的。 webRequest.onBeforeRequest fires prior to the request being made. webRequest.onBeforeRequest在发出请求之前触发。 The data you want is something that is provided by the server in response to the request. 所需的数据是服务器响应请求提供的数据。 You are looking for header information. 您正在寻找标题信息。 The earliest this is available is in the webRequest.onHeadersReceived event. 最早可用的是在webRequest.onHeadersReceived事件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 阻止通过Chrome扩展程序按内容类型下载 - Block downloading by Content-Type via Chrome Extension 在 JavaScript 中获取内容类型的默认文件扩展名? - Getting the default file extension for a content-type in JavaScript? Chrome扩展程序webRequest.onBeforeRequest - Chrome extension webRequest.onBeforeRequest Chrome扩展程序webRequest.onBeforeRequest取消页面 - Chrome Extension webRequest.onBeforeRequest Cancel Page Chrome扩展程序如何删除chrome.webRequest.onBeforeRequest上的侦听器 - Chrome extension How to remove a Listener on chrome.webRequest.onBeforeRequest 是否有任何基于文件扩展名计算内容类型的JavaScript库? - Is there any javascript library that calculate content-type based on file extension? PHP:如何提供正确的内容类型(取决于文件扩展名?)? - PHP: how to serve right content-type (depending on file extension?)? firefox扩展如何检测加载的页面的内容类型? - how can a firefox extension detect content-type of the page loaded? Chrome 扩展:如何从 onBeforeRequest 函数调用同步请求 - Chrome extension: how to call sync request from onBeforeRequest function Firefox Addon中的OnBeforeRequest URL重定向(从Chrome扩展转换) - OnBeforeRequest URL redirect in Firefox Addon (Conversion from Chrome Extension)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM