Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Microsoft Playwright WkInterceptableRequest

From Leeroopedia
Revision as of 11:38, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Microsoft_Playwright_WkInterceptableRequest.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Template:Implementation Page

Overview

WKInterceptableRequest wraps WebKit network requests with interception capabilities, enabling request modification, fulfillment, and abort functionality for route handling.

Description

The WKInterceptableRequest class bridges between WebKit's Network domain events and Playwright's network.Request and network.Route abstractions. It processes requestWillBeSent events, creates Playwright Request objects with proper resource types, and provides methods for request interception including:

  • abort -- cancels the request with a mapped error reason
  • fulfill -- provides a custom response
  • continue -- continues with optionally modified parameters

The module includes an errorReasons mapping that translates Playwright's error reason strings to WebKit's ResourceErrorType values.

Usage

Created internally by the WebKit page network event handlers.

Code Reference

Source Location

packages/playwright-core/src/server/webkit/wkInterceptableRequest.ts (188 lines)

Class Signature

export class WKInterceptableRequest {
  readonly request: network.Request;
  constructor(session: WKSession, frame: frames.Frame, event: Protocol.Network.requestWillBeSentPayload, redirectedFrom: WKInterceptableRequest | null, documentId: string | undefined)
  async abort(errorCode: string): Promise<void>
  async fulfill(response: types.NormalizedFulfillResponse): Promise<void>
  async continue(overrides: types.NormalizedContinueOverrides): Promise<void>
}

Import

import { WKInterceptableRequest } from './server/webkit/wkInterceptableRequest';

I/O Contract

Inputs

  • session: WKSession -- WebKit protocol session
  • frame: Frame -- the frame that originated the request
  • event -- WebKit requestWillBeSent protocol event
  • redirectedFrom -- the request this was redirected from, if any

Outputs

  • Creates network.Request objects with resource type, headers, and post data
  • Sends interception commands (Network.interceptRequestWithResponse, etc.) via the session

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment