网络域允许追踪页面的网络活动。它暴露了关于http、文件、数据及其他请求和响应的信息,包括它们的头部、主体、时间等。
EN
Network domain allows tracking network activities of the page. It exposes information about http, file, data and other requests and responses, their headers, bodies, timing, etc.
✅️️ Methods
🔨Network.clearBrowserCache
清除浏览器缓存。
EN
🔨Network.clearBrowserCookies
清除浏览器Cookie。
EN
🔨Network.deleteCookies
删除具有匹配名称和URL或域名/路径/分区键对的浏览器Cookie。
EN
Deletes browser cookies with matching name and url or domain/path/partitionKey pair.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| name | ✔️ | | string | 要移除的Cookie的名称。 | ENName of the cookies to remove. |
| url | | | string | 如果指定,将删除所有具有给定名称且域名和路径与提供的URL匹配的cookie。 | ENIf specified, deletes all the cookies with the given name where domain and path match provided URL. |
| domain | | | string | 如果指定,仅删除具有确切域名的Cookie。 | ENIf specified, deletes only cookies with the exact domain. |
| path | | | string | 如果指定,仅删除路径完全匹配的''和``内的内容的cookie。 | ENIf specified, deletes only cookies with the exact path. |
| partitionKey | | 🧪 | CookiePartitionKey | 如果指定,仅删除具有给定名称和分区键的Cookie,其中所有分区键属性均与Cookie分区键属性匹配。 | ENIf specified, deletes only cookies with the the given name and partitionKey where all partition key attributes match the cookie partition key attribute. |
🔨Network.disable
禁用网络跟踪,防止网络事件被发送到客户端。
EN
Disables network tracking, prevents network events from being sent to the client.
🔨Network.enable
启用网络追踪功能,网络事件现在将发送给客户端。
EN
Enables network tracking, network events will now be delivered to the client.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| maxTotalBufferSize | | 🧪 | integer | 保留网络负载(XHR等)时使用的缓冲区大小(以字节为单位)。这是此DevTools会话将收集的最大字节数。 | ENBuffer size in bytes to use when preserving network payloads (XHRs, etc). This is the maximum number of bytes that will be collected by this DevTools session. |
| maxResourceBufferSize | | 🧪 | integer | 每个资源的缓冲区大小(以字节为单位),用于保存网络负载(XHR等)。 | ENPer-resource buffer size in bytes to use when preserving network payloads (XHRs, etc). |
| maxPostDataSize | | | integer | 请求将发送通知中包含的最长帖子正文大小(以字节为单位) | ENLongest post body size (in bytes) that would be included in requestWillBeSent notification |
| reportDirectSocketTraffic | | 🧪 | boolean | 是否应报告DirectSocket分块发送/接收事件。 | ENWhether DirectSocket chunk send/receive events should be reported. |
| enableDurableMessages | | 🧪 | boolean | 启用将响应体存储在渲染器外部,以便这些响应体能在跨进程导航中保留。需要设置maxTotalBufferSize。当前默认值为false。由于在发出Runtime.runIfWaitingForDebugger之前等待Network.enable可能导致死锁,该字段正在被弃用,转而支持专用的configureDurableMessages命令。 | ENEnable storing response bodies outside of renderer, so that these survive a cross-process navigation. Requires maxTotalBufferSize to be set. Currently defaults to false. This field is being deprecated in favor of the dedicated configureDurableMessages command, due to the possibility of deadlocks when awaiting Network.enable before issuing Runtime.runIfWaitingForDebugger. |
🔨Network.getCookies
返回当前URL的所有浏览器Cookie。根据后端支持情况,将在cookies字段中返回详细的Cookie信息。
EN
Returns all browser cookies for the current URL. Depending on the backend support, will return detailed cookie information in the cookies field.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| urls | | | array[string] | 将获取适用Cookie的URL列表。如果未指定,则假定设置为包含页面及其所有子框架URL的列表。 | ENThe list of URLs for which applicable cookies will be fetched. If not specified, it's assumed to be set to the list containing the URLs of the page and all of its subframes. |
| 返回对象 | 类型 | 描述 | 原文 |
|---|
| cookies | array[Cookie] | Cookie对象数组。 | ENArray of cookie objects. |
🔨Network.getRequestPostData
返回随请求发送的发布数据。当请求未附带数据时,将返回错误。
EN
Returns post data sent with the request. Returns an error when no data was sent with the request.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| requestId | ✔️ | | RequestId | 获取内容的网络请求标识符。 | ENIdentifier of the network request to get content for. |
| 返回对象 | 类型 | 描述 | 原文 |
|---|
| postData | string | 请求体字符串,省略多部分请求中的文件 | ENRequest body string, omitting files from multipart requests |
| base64Encoded | boolean | 是的,如果内容是以base64格式发送的。 | ENTrue, if content was sent as base64. |
🔨Network.getResponseBody
返回为给定请求提供的内容。
EN
Returns content served for the given request.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| requestId | ✔️ | | RequestId | 获取内容的网络请求标识符。 | ENIdentifier of the network request to get content for. |
| 返回对象 | 类型 | 描述 | 原文 |
|---|
| body | string | 响应正文。 | ENResponse body. |
| base64Encoded | boolean | 是的,如果内容是以 base64 格式发送的。 | ENTrue, if content was sent as base64. |
🔨Network.setBypassServiceWorker
切换是否忽略每个请求的服务工作者。
EN
Toggles ignoring of service worker for each request.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| bypass | ✔️ | | boolean | 绕过服务工作者并从网络加载。 | ENBypass service worker and load from network. |
🔨Network.setCacheDisabled
切换是否忽略每个请求的缓存。如果为true,则不会使用缓存。
EN
Toggles ignoring cache for each request. If true, cache will not be used.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| cacheDisabled | ✔️ | | boolean | 缓存禁用状态。 | ENCache disabled state. |
🔨Network.setCookie
使用给定的cookie数据设置一个cookie;如果存在等效的cookie,可能会覆盖它们。
EN
Sets a cookie with the given cookie data; may overwrite equivalent cookies if they exist.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| name | ✔️ | | string | Cookie name. | ENCookie name. |
| value | ✔️ | | string | Cookie值。 | ENCookie value. |
| url | | | string | 与cookie设置相关联的请求URI。该值会影响所创建cookie的默认域名、路径、源端口和源方案值。 | ENThe request-URI to associate with the setting of the cookie. This value can affect the default domain, path, source port, and source scheme values of the created cookie. |
| domain | | | string | Cookie domain. | ENCookie domain. |
| path | | | string | Cookie 路径。 | ENCookie path. |
| secure | | | boolean | 如果 cookie 是安全的,则为 True。 | ENTrue if cookie is secure. |
| httpOnly | | | boolean | 如果 cookie 是 http-only,则为 True。 | ENTrue if cookie is http-only. |
| sameSite | | | CookieSameSite | Cookie SameSite 类型。 | ENCookie SameSite type. |
| expires | | | TimeSinceEpoch | Cookie 过期日期,如果未设置则为会话 Cookie | ENCookie expiration date, session cookie if not set |
| priority | | 🧪 | CookiePriority | Cookie 优先级类型。 | ENCookie Priority type. |
| sourceScheme | | 🧪 | CookieSourceScheme | Cookie 来源方案类型。 | ENCookie source scheme type. |
| sourcePort | | 🧪 | integer | Cookie 源端口。有效值为 {-1, [1, 65535]},-1 表示未指定端口。未指定的端口值允许协议客户端模拟旧版 Cookie 的端口作用域。这是一个临时功能,未来将被移除。 | ENCookie source port. Valid values are {-1, [1, 65535]}, -1 indicates an unspecified port. An unspecified port value allows protocol clients to emulate legacy cookie scope for the port. This is a temporary ability and it will be removed in the future. |
| partitionKey | | 🧪 | CookiePartitionKey | Cookie partition key。如果未设置,cookie将被设置为未分区。 | ENCookie partition key. If not set, the cookie will be set as not partitioned. |
| 返回对象 | 类型 | 描述 | 原文 |
|---|
| success | boolean | 始终设置为true。如果发生错误,响应将指示协议错误。 | ENAlways set to true. If an error occurs, the response indicates protocol error. |
🔨Network.setCookies
设置给定的cookies。
EN
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| cookies | ✔️ | | array[CookieParam] | 要设置的Cookies。 | ENCookies to be set. |
指定是否始终随此页面的请求发送额外的HTTP头。
EN
Specifies whether to always send extra HTTP headers with the requests from this page.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| headers | ✔️ | | Headers | 包含额外HTTP头部的映射。 | ENMap with extra HTTP headers. |
🔨Network.setUserAgentOverride
允许使用给定的字符串覆盖用户代理。
EN
Allows overriding user agent with the given string.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| userAgent | ✔️ | | string | 要使用的用户代理。 | ENUser agent to use. |
| acceptLanguage | | | string | 要模拟的浏览器语言。 | ENBrowser language to emulate. |
| platform | | | string | 平台 navigator.platform 应该返回。 | ENThe platform navigator.platform should return. |
| userAgentMetadata | | 🧪 | Emulation.UserAgentMetadata | 在Sec-CH-UA-*头部中发送,并在navigator.userAgentData中返回 | ENTo be sent in Sec-CH-UA-* headers and returned in navigator.userAgentData |
🔨Network.canClearBrowserCache❌️
指示是否支持清除浏览器缓存。
EN
Tells whether clearing browser cache is supported.
| 返回对象 | 类型 | 描述 | 原文 |
|---|
| result | boolean | 如果浏览器缓存可以被清除,则为真。 | ENTrue if browser cache can be cleared. |
🔨Network.canClearBrowserCookies❌️
指示是否支持清除浏览器Cookie。
EN
Tells whether clearing browser cookies is supported.
| 返回对象 | 类型 | 描述 | 原文 |
|---|
| result | boolean | 如果浏览器cookie可以被清除,则为True。 | ENTrue if browser cookies can be cleared. |
🔨Network.canEmulateNetworkConditions❌️
判断是否支持网络条件模拟。
EN
Tells whether emulation of network conditions is supported.
| 返回对象 | 类型 | 描述 | 原文 |
|---|
| result | boolean | 如果支持网络条件模拟,则为真。 | ENTrue if emulation of network conditions is supported. |
🔨Network.emulateNetworkConditions❌️
激活网络条件模拟。此命令已弃用,推荐使用 emulateNetworkConditionsByRule 和 overrideNetworkState 命令,两者结合使用可达到相同效果。
EN
Activates emulation of network conditions. This command is deprecated in favor of the emulateNetworkConditionsByRule and overrideNetworkState commands, which can be used together to the same effect.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| offline | ✔️ | | boolean | 模拟网络断开的真实情况。 | ENTrue to emulate internet disconnection. |
| latency | ✔️ | | number | 从请求发送到响应头接收的最小延迟(毫秒)。 | ENMinimum latency from request sent to response headers received (ms). |
| downloadThroughput | ✔️ | | number | 最大聚合下载吞吐量(字节/秒)。-1 表示禁用下载限流。 | ENMaximal aggregated download throughput (bytes/sec). -1 disables download throttling. |
| uploadThroughput | ✔️ | | number | 最大聚合上传吞吐量(字节/秒)。-1 表示禁用上传限流。 | ENMaximal aggregated upload throughput (bytes/sec). -1 disables upload throttling. |
| connectionType | | | ConnectionType | 如果已知,连接类型。 | ENConnection type if known. |
| packetLoss | | 🧪 | number | WebRTC 数据包丢失率(百分比,0-100)。0 表示禁用数据包丢失模拟,100 表示丢弃所有数据包。 | ENWebRTC packet loss (percent, 0-100). 0 disables packet loss emulation, 100 drops all the packets. |
| packetQueueLength | | 🧪 | integer | WebRTC 数据包队列长度(数据包)。0 表示移除任何队列长度限制。 | ENWebRTC packet queue length (packet). 0 removes any queue length limitations. |
| packetReordering | | 🧪 | boolean | WebRTC packetReordering 功能。 | ENWebRTC packetReordering feature. |
🔨Network.getAllCookies❌️
返回所有浏览器Cookie。根据后端支持情况,将在cookies字段中返回详细的Cookie信息。已弃用。请改用Storage.getCookies。
EN
Returns all browser cookies. Depending on the backend support, will return detailed cookie information in the cookies field. Deprecated. Use Storage.getCookies instead.
| 返回对象 | 类型 | 描述 | 原文 |
|---|
| cookies | array[Cookie] | Cookie 对象数组。 | ENArray of cookie objects. |
🔨Network.clearAcceptedEncodingsOverride🧪
清除由 setAcceptedEncodings 设置的已接受编码
EN
Clears accepted encodings set by setAcceptedEncodings
配置将响应体存储在渲染器外部,使其在跨进程导航中得以保留。如果未设置 maxTotalBufferSize,则禁用持久消息。
EN
Configures storing response bodies outside of renderer, so that these survive a cross-process navigation. If maxTotalBufferSize is not set, durable messages are disabled.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| maxTotalBufferSize | | | integer | 保留网络负载(XHR等)时使用的缓冲区大小(以字节为单位)。 | ENBuffer size in bytes to use when preserving network payloads (XHRs, etc). |
| maxResourceBufferSize | | | integer | 当保留网络负载(XHR等)时,每个资源使用的缓冲区大小(以字节为单位)。 | ENPer-resource buffer size in bytes to use when preserving network payloads (XHRs, etc). |
🔨Network.emulateNetworkConditionsByRule🧪
使用URL匹配模式为单个请求激活网络条件模拟。与已弃用的Network.emulateNetworkConditions不同,此方法不会影响navigator状态。如需显式修改navigator行为,请使用Network.overrideNetworkState。
EN
Activates emulation of network conditions for individual requests using URL match patterns. Unlike the deprecated Network.emulateNetworkConditions this method does not affect navigator state. Use Network.overrideNetworkState to explicitly modify navigator behavior.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| offline | ✔️ | | boolean | True to emulate internet disconnection. | ENTrue to emulate internet disconnection. |
| matchedNetworkConditions | ✔️ | | array[NetworkConditions] | 配置请求匹配条件。如果多个条目匹配一个请求,则第一个条目生效。通过将条件的 urlPattern 留空,可以配置全局条件。这些全局条件也适用于 P2P 连接的节流控制。 | ENConfigure conditions for matching requests. If multiple entries match a request, the first entry wins. Global conditions can be configured by leaving the urlPattern for the conditions empty. These global conditions are also applied for throttling of p2p connections. |
| 返回对象 | 类型 | 描述 | 原文 |
|---|
| ruleIds | array[string] | 每个匹配网络条件条目的唯一标识符。该标识符将包含在受规则影响的请求的requestWillBeSentExtraInfo中。 | ENAn id for each entry in matchedNetworkConditions. The id will be included in the requestWillBeSentExtraInfo for requests affected by a rule. |
🔨Network.enableDeviceBoundSessions🧪
设置跟踪设备绑定的会话并获取初始会话集。
EN
Sets up tracking device bound sessions and fetching of initial set of sessions.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| enable | ✔️ | | boolean | 是否启用或禁用事件。 | ENWhether to enable or disable events. |
🔨Network.enableReportingApi🧪
启用Reporting API的跟踪功能,现在Reporting API生成的事件将被发送到客户端。启用此功能会为所有现有报告触发'reportingApiReportAdded'事件。
EN
Enables tracking for the Reporting API, events generated by the Reporting API will now be delivered to the client. Enabling triggers 'reportingApiReportAdded' for all existing reports.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| enable | ✔️ | | boolean | 是否启用或禁用Reporting API的事件 | ENWhether to enable or disable events for the Reporting API |
🔨Network.fetchSchemefulSite🧪
获取特定来源的''schemeful site''。
EN
Fetches the schemeful site for a specific origin.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| origin | ✔️ | | string | URL 来源。 | ENThe URL origin. |
| 返回对象 | 类型 | 描述 | 原文 |
|---|
| schemefulSite | string | 对应的schemeful site。 | ENThe corresponding schemeful site. |
🔨Network.getCertificate🧪
返回DER编码的证书。
EN
Returns the DER-encoded certificate.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| origin | ✔️ | | string | 获取证书的来源。 | ENOrigin to get certificate for. |
| 返回对象 | 类型 | 描述 | 原文 |
|---|
| tableNames | array[string] | | |
🔨Network.getResponseBodyForInterception🧪
返回为当前被拦截请求提供的内容。
EN
Returns content served for the given currently intercepted request.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| interceptionId | ✔️ | | InterceptionId | 获取请求正文的拦截请求标识符。 | ENIdentifier for the intercepted request to get body for. |
| 返回对象 | 类型 | 描述 | 原文 |
|---|
| body | string | 响应正文。 | ENResponse body. |
| base64Encoded | boolean | 是的,如果内容是以base64格式发送的。 | ENTrue, if content was sent as base64. |
🔨Network.getSecurityIsolationStatus🧪
返回有关COEP/COOP隔离状态的信息。
EN
Returns information about the COEP/COOP isolation status.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| frameId | | | Page.FrameId | 如果未提供frameId,则提供目标的状态。 | ENIf no frameId is provided, the status of the target is provided. |
🔨Network.loadNetworkResource🧪
获取资源并返回内容。
EN
Fetches the resource and returns the content.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| frameId | | | Page.FrameId | 获取资源的框架ID。对于框架目标是必需的,对于工作线程目标则应省略。 | ENFrame id to get the resource for. Mandatory for frame targets, and should be omitted for worker targets. |
| url | ✔️ | | string | 获取内容的资源URL。 | ENURL of the resource to get content for. |
| options | ✔️ | | LoadNetworkResourceOptions | 请求的选项。 | ENOptions for the request. |
🔨Network.overrideNetworkState🧪
覆盖 ''navigator.onLine'' 和 ''navigator.connection'' 的状态。
EN
Override the state of navigator.onLine and navigator.connection.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| offline | ✔️ | | boolean | True to emulate internet disconnection. | ENTrue to emulate internet disconnection. |
| latency | ✔️ | | number | 从请求发送到响应头接收的最小延迟(毫秒)。 | ENMinimum latency from request sent to response headers received (ms). |
| downloadThroughput | ✔️ | | number | 最大聚合下载吞吐量(字节/秒)。-1 表示禁用下载限流。 | ENMaximal aggregated download throughput (bytes/sec). -1 disables download throttling. |
| uploadThroughput | ✔️ | | number | 最大聚合上传吞吐量(字节/秒)。-1 表示禁用上传限流。 | ENMaximal aggregated upload throughput (bytes/sec). -1 disables upload throttling. |
| connectionType | | | ConnectionType | 如果已知,连接类型。 | ENConnection type if known. |
🔨Network.replayXHR🧪
此方法发送一个与原始请求完全相同的新XMLHttpRequest。以下参数应保持一致:method、url、async、request body、extra headers、withCredentials attribute、user、password。
EN
This method sends a new XMLHttpRequest which is identical to the original one. The following parameters should be identical: method, url, async, request body, extra headers, withCredentials attribute, user, password.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| requestId | ✔️ | | RequestId | 重放XHR的标识符。 | ENIdentifier of XHR to replay. |
🔨Network.searchInResponseBody🧪
在响应内容中搜索指定字符串。
EN
Searches for given string in response content.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| requestId | ✔️ | | RequestId | 搜索网络响应的标识符。 | ENIdentifier of the network response to search. |
| query | ✔️ | | string | 要搜索的字符串。 | ENString to search for. |
| caseSensitive | | | boolean | 如果为真,则搜索区分大小写。 | ENIf true, search is case sensitive. |
| isRegex | | | boolean | 如果为真,则将字符串参数视为正则表达式。 | ENIf true, treats string parameter as regex. |
🔨Network.setAcceptedEncodings🧪
设置一个将被接受的内容编码列表。空列表意味着不接受任何编码。
EN
Sets a list of content encodings that will be accepted. Empty list means no encoding is accepted.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| encodings | ✔️ | | array[ContentEncoding] | 接受的编码格式列表。 | ENList of accepted content encodings. |
🔨Network.setAttachDebugStack🧪
指定是否在请求中附加页面脚本堆栈ID
EN
Specifies whether to attach a page script stack id in requests
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| enabled | ✔️ | | boolean | 是否附加页面脚本堆栈以用于调试目的。 | ENWhether to attach a page script stack for debugging purpose. |
🔨Network.setBlockedURLs🧪
阻止来自加载的URL。
EN
Blocks URLs from loading.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| urlPatterns | | | array[BlockPattern] | 按照给定的顺序匹配模式。这些模式也优先于 urls 中定义的任何通配符模式。 | ENPatterns to match in the order in which they are given. These patterns also take precedence over any wildcard patterns defined in urls. |
| urls | | ❌️ | array[string] | 要屏蔽的URL模式。允许使用通配符('*')。 | ENURL patterns to block. Wildcards ('*') are allowed. |
🔨Network.setCookieControls🧪
设置第三方 Cookie 访问控制''需要刷新页面才能观察到新的 Cookie 行为``
EN
Sets Controls for third-party cookie access Page reload is required before the new cookie behavior will be observed
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| enableThirdPartyCookieRestriction | ✔️ | | boolean | 是否启用了第三方Cookie限制。 | ENWhether 3pc restriction is enabled. |
| disableThirdPartyCookieMetadata | ✔️ | | boolean | 是否应启用第三方Cookie宽限期例外;默认情况下为false。 | ENWhether 3pc grace period exception should be enabled; false by default. |
| disableThirdPartyCookieHeuristics | ✔️ | | boolean | 是否应启用第三方Cookie启发式例外;默认情况下为false。 | ENWhether 3pc heuristics exceptions should be enabled; false by default. |
🔨Network.streamResourceContent🧪
启用对给定请求ID(requestId)的响应流式传输。如果启用,dataReceived事件将包含流式传输期间接收到的数据。
EN
Enables streaming of the response for the given requestId. If enabled, the dataReceived event contains the data that was received during streaming.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| requestId | ✔️ | | RequestId | 要流式传输的请求标识符。 | ENIdentifier of the request to stream. |
| 返回对象 | 类型 | 描述 | 原文 |
|---|
| bufferedData | string | 在流式传输启用前已缓冲的数据。(通过JSON传递时编码为base64字符串) | ENData that has been buffered until streaming is enabled. (Encoded as a base64 string when passed over JSON) |
🔨Network.takeResponseBodyForInterceptionAsStream🧪
返回表示响应体的流的一个句柄。请注意,在此命令之后,被拦截的请求不能按原样继续——您需要取消它或提供响应体。该流仅支持顺序读取,如果指定了位置,IO.read 将会失败。
EN
Returns a handle to the stream representing the response body. Note that after this command, the intercepted request can't be continued as is -- you either need to cancel it or to provide the response body. The stream only supports sequential read, IO.read will fail if the position is specified.
🔨Network.continueInterceptedRequest🧪❌️
对Network.requestIntercepted的响应,该响应要么修改请求以继续执行任何修改,要么阻止它,要么使用提供的响应字节完成它。如果因此发生网络获取并遇到重定向,将发送一个额外的Network.requestIntercepted事件,并带有相同的InterceptionId。已弃用,请改用Fetch.continueRequest、Fetch.fulfillRequest和Fetch.failRequest。
EN
Response to Network.requestIntercepted which either modifies the request to continue with any modifications, or blocks it, or completes it with the provided response bytes. If a network fetch occurs as a result which encounters a redirect an additional Network.requestIntercepted event will be sent with the same InterceptionId. Deprecated, use Fetch.continueRequest, Fetch.fulfillRequest and Fetch.failRequest instead.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| interceptionId | ✔️ | | InterceptionId | | |
| errorReason | | | ErrorReason | 如果设置此项,将导致请求因给定原因而失败。对于标记为 isNavigationRequest 的请求,传递 Aborted 也会取消导航。不得在响应 authChallenge 时设置。 | ENIf set this causes the request to fail with the given reason. Passing Aborted for requests marked with isNavigationRequest also cancels the navigation. Must not be set in response to an authChallenge. |
| rawResponse | | | string | 如果设置,请求将使用提供的base64编码原始响应(包含HTTP状态行和头部信息等)完成。不得在响应authChallenge时设置此选项。(通过JSON传递时编码为base64字符串) | ENIf set the requests completes using with the provided base64 encoded raw response, including HTTP status line and headers etc... Must not be set in response to an authChallenge. (Encoded as a base64 string when passed over JSON) |
| url | | | string | 如果设置了该选项,请求的URL将被修改,且这种修改对页面不可见。不得在响应authChallenge时设置。 | ENIf set the request url will be modified in a way that's not observable by page. Must not be set in response to an authChallenge. |
| method | | | string | 如果设置此选项,将允许覆盖请求方法。不得在响应身份验证质询时设置。 | ENIf set this allows the request method to be overridden. Must not be set in response to an authChallenge. |
| postData | | | string | 如果设置此项,将允许设置 postData。在响应 authChallenge 时不得设置。 | ENIf set this allows postData to be set. Must not be set in response to an authChallenge. |
| headers | | | Headers | 如果设置此选项,允许更改请求头。在响应身份验证挑战时不得设置。 | ENIf set this allows the request headers to be changed. Must not be set in response to an authChallenge. |
| authChallengeResponse | | | AuthChallengeResponse | 对带有身份验证挑战(authChallenge)的请求拦截(requestIntercepted)的响应。否则不得设置。 | ENResponse to a requestIntercepted with an authChallenge. Must not be set otherwise. |
🔨Network.setRequestInterception🧪❌️
设置要拦截的请求,这些请求需匹配提供的模式并可选择性地匹配资源类型。已弃用,请改用 Fetch.enable。
EN
Sets the requests to intercept that match the provided patterns and optionally resource types. Deprecated, please use Fetch.enable instead.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| patterns | ✔️ | | array[RequestPattern] | 符合这些模式中任意一个的请求将被转发,并等待相应的''continueInterceptedRequest''调用。 | ENRequests matching any of these patterns will be forwarded and wait for the corresponding continueInterceptedRequest call. |
✅️️ Events
👋Network.dataReceived
当通过网络接收到数据块时触发。
EN
Fired when data chunk was received over the network.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| requestId | ✔️ | | RequestId | 请求标识符。 | ENRequest identifier. |
| timestamp | ✔️ | | MonotonicTime | 时间戳。 | ENTimestamp. |
| dataLength | ✔️ | | integer | 数据块长度。 | ENData chunk length. |
| encodedDataLength | ✔️ | | integer | 实际接收的字节数(对于压缩编码,可能小于数据长度)。 | ENActual bytes received (might be less than dataLength for compressed encodings). |
| data | | 🧪 | string | 已接收的数据。(在通过JSON传递时,编码为base64字符串) | ENData that was received. (Encoded as a base64 string when passed over JSON) |
👋Network.eventSourceMessageReceived
当接收到 EventSource 消息时触发。
EN
Fired when EventSource message is received.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| requestId | ✔️ | | RequestId | 请求标识符。 | ENRequest identifier. |
| timestamp | ✔️ | | MonotonicTime | 时间戳。 | ENTimestamp. |
| eventName | ✔️ | | string | 消息类型。 | ENMessage type. |
| eventId | ✔️ | | string | 消息标识符。 | ENMessage identifier. |
| data | ✔️ | | string | 消息内容。 | ENMessage content. |
👋Network.loadingFailed
当HTTP请求加载失败时触发。
EN
Fired when HTTP request has failed to load.
👋Network.loadingFinished
当HTTP请求完成加载时触发。
EN
Fired when HTTP request has finished loading.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| requestId | ✔️ | | RequestId | 请求标识符。 | ENRequest identifier. |
| timestamp | ✔️ | | MonotonicTime | 时间戳。 | ENTimestamp. |
| encodedDataLength | ✔️ | | number | 此请求接收的总字节数。 | ENTotal number of bytes received for this request. |
👋Network.requestServedFromCache
如果请求最终从缓存加载,则触发此事件。
EN
Fired if request ended up loading from cache.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| requestId | ✔️ | | RequestId | 请求标识符。 | ENRequest identifier. |
👋Network.requestWillBeSent
当页面即将发送HTTP请求时触发。
EN
Fired when page is about to send HTTP request.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| requestId | ✔️ | | RequestId | 请求标识符。 | ENRequest identifier. |
| loaderId | ✔️ | | LoaderId | Loader标识符。如果请求是从worker获取的,则为空字符串。 | ENLoader identifier. Empty string if the request is fetched from worker. |
| documentURL | ✔️ | | string | 此请求加载的文档的URL。 | ENURL of the document this request is loaded for. |
| request | ✔️ | | Request | 请求数据。 | ENRequest data. |
| timestamp | ✔️ | | MonotonicTime | 时间戳。 | ENTimestamp. |
| wallTime | ✔️ | | TimeSinceEpoch | Timestamp. | ENTimestamp. |
| initiator | ✔️ | | Initiator | 请求发起者。 | ENRequest initiator. |
| redirectHasExtraInfo | ✔️ | 🧪 | boolean | 当redirectResponse被填充时,此标志指示是否将为刚刚重定向的请求发出requestWillBeSentExtraInfo和responseReceivedExtraInfo事件。 | ENIn the case that redirectResponse is populated, this flag indicates whether requestWillBeSentExtraInfo and responseReceivedExtraInfo events will be or were emitted for the request which was just redirected. |
| redirectResponse | | | Response | 重定向响应数据。 | ENRedirect response data. |
| type | | | ResourceType | 此资源的类型。 | ENType of this resource. |
| frameId | | | Page.FrameId | Frame identifier. | ENFrame identifier. |
| hasUserGesture | | | boolean | 请求是否由用户手势发起。默认为 false。 | ENWhether the request is initiated by a user gesture. Defaults to false. |
| renderBlockingBehavior | | 🧪 | RenderBlockingBehavior | 请求的渲染阻塞行为。 | ENThe render-blocking behavior of the request. |
👋Network.responseReceived
当HTTP响应可用时触发。
EN
Fired when HTTP response is available.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| requestId | ✔️ | | RequestId | 请求标识符。 | ENRequest identifier. |
| loaderId | ✔️ | | LoaderId | 加载器标识符。如果请求是从工作线程获取的,则为空字符串。 | ENLoader identifier. Empty string if the request is fetched from worker. |
| timestamp | ✔️ | | MonotonicTime | 时间戳。 | ENTimestamp. |
| type | ✔️ | | ResourceType | 资源类型。 | ENResource type. |
| response | ✔️ | | Response | 响应数据。 | ENResponse data. |
| hasExtraInfo | ✔️ | 🧪 | boolean | 表示对于此请求,是否将或已经触发了 requestWillBeSentExtraInfo 和 responseReceivedExtraInfo 事件。 | ENIndicates whether requestWillBeSentExtraInfo and responseReceivedExtraInfo events will be or were emitted for this request. |
| frameId | | | Page.FrameId | 帧标识符。 | ENFrame identifier. |
👋Network.webSocketClosed
当WebSocket关闭时触发。
EN
Fired when WebSocket is closed.
👋Network.webSocketCreated
在WebSocket创建时触发。
EN
Fired upon WebSocket creation.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| requestId | ✔️ | | RequestId | 请求标识符。 | ENRequest identifier. |
| url | ✔️ | | string | WebSocket 请求 URL。 | ENWebSocket request URL. |
| initiator | | | Initiator | 请求发起方。 | ENRequest initiator. |
👋Network.webSocketFrameError
当WebSocket消息错误发生时触发。
EN
Fired when WebSocket message error occurs.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|
| requestId | ✔️ | | RequestId | 请求标识符。 | ENRequest identifier. |
| timestamp | ✔️ | | MonotonicTime | 时间戳。 | ENTimestamp. |
| errorMessage | ✔️ | | string | WebSocket 错误信息。 | ENWebSocket error message. |
👋Network.webSocketFrameReceived
当接收到WebSocket消息时触发。
EN
Fired when WebSocket message is received.
👋Network.webSocketFrameSent
当WebSocket消息被发送时触发。
EN
Fired when WebSocket message is sent.
👋Network.webSocketHandshakeResponseReceived
当WebSocket握手响应可用时触发。
EN
Fired when WebSocket handshake response becomes available.
👋Network.webSocketWillSendHandshakeRequest