问题
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