DevTool协议如何提供"resourceType"值的定义? [英] How is defined `resourceType` value provided by the DevTool protocol?
问题描述
使用Puppeteer或Chrome DevTools API时,您可以获得resourceType
的值(在Puppeteer中的Request
对象上和在Chrome DevTools中的Page
对象上).
While using Puppeteer or Chrome DevTools APIs, you can get a value for resourceType
(on Request
object in Puppeteer and on Page
object in Chrome DevTools).
渲染引擎"如何建立此值(如文档中所述)?
How does this value is establish by the "rendering engine" (as called in the documentation)?
可能的值为:Document
,Stylesheet
,Image
,Media
,Font
,Script
,TextTrack
,XHR
,Fetch
,EventSource
,WebSocket
,Manifest
,Other
Possible values being: Document
, Stylesheet
, Image
, Media
, Font
, Script
, TextTrack
, XHR
, Fetch
, EventSource
, WebSocket
, Manifest
, Other
API文档: Puppeteer API 和 Chrome DevTools API
Similar question on stackoverflow: Is There any way to get all mime type by the resourceType of chrome
推荐答案
最后,我在Chromium使用的WebKit源代码中找到了处理该源代码的源代码.
Finally, I found the source code that handle that in the WebKit source code used by Chromium.
首先,文档中称为渲染引擎"的是WebKit引擎(至少是铬源提供的版本).
First, what is called "rendering engine" in the documentation is the WebKit engine (at least the version provided with the chromium sources).
第二,无法轻松地知道如何为每个类别标记资源.
Second, there is no way to easily know how a resource will be tag for each category.
最简单的部分是以下类别:Document
,Stylesheet
,Image
,Media
,Font
和Script
.它使用mimeType
和URL路径部分提供的扩展名. 此响应中详细介绍了映射.
The easy part is for the categories: Document
, Stylesheet
, Image
, Media
, Font
and Script
. It use the mimeType
and the extension provided by the path part of the URL. The mapping is detailed in this response.
对于其他类别(TextTrack
,XHR
,Fetch
,EventSource
,WebSocket
和Manifest
),似乎是在处理给定资源的过程中通过自定义逻辑建立的WebKit.
For the other categories (TextTrack
, XHR
, Fetch
, EventSource
, WebSocket
and Manifest
), it seems that it is establish by custom logic during the processing of the given resource by WebKit.
The source code is available in the chromium repository: ./third_party/WebKit/Source/devtools/front_end/common/ResourceType.js.
这篇关于DevTool协议如何提供"resourceType"值的定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!