DevTool协议如何提供"resourceType"值的定义? [英] How is defined `resourceType` value provided by the DevTool protocol?

查看:100
本文介绍了DevTool协议如何提供"resourceType"值的定义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用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)?

可能的值为:DocumentStylesheetImageMediaFontScriptTextTrackXHRFetchEventSourceWebSocketManifestOther

Possible values being: Document, Stylesheet, Image, Media, Font, Script, TextTrack, XHR, Fetch, EventSource, WebSocket, Manifest, Other

API文档: Puppeteer API Chrome DevTools API

关于stackoverflow的类似问题:

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.

最简单的部分是以下类别:DocumentStylesheetImageMediaFontScript.它使用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.

对于其他类别(TextTrackXHRFetchEventSourceWebSocketManifest),似乎是在处理给定资源的过程中通过自定义逻辑建立的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.

可在Chrome存储库中找到源代码:

The source code is available in the chromium repository: ./third_party/WebKit/Source/devtools/front_end/common/ResourceType.js.

这篇关于DevTool协议如何提供"resourceType"值的定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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