How is defined `resourceType` value provided by the DevTool protocol?

最后都变了- 提交于 2019-12-22 09:25:04

问题


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


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

API documentation: Puppeteer API and Chrome DevTools API

Similar question on stackoverflow: Is There any way to get all mime type by the resourceType of chrome


回答1:


Finally, I found the source code that handle that in the WebKit source code used by Chromium.

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.

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.

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.



来源:https://stackoverflow.com/questions/47083776/how-is-defined-resourcetype-value-provided-by-the-devtool-protocol

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!