目录

Class (WebSchemeHandlerRequest)

Represents a request intercepted by the WebSchemeHandler object.

  • The initial APIs of this module are supported since API version 9. Updates will be marked with a superscript to indicate their earliest API version.

  • The initial APIs of this class are supported since API version 12.

  • The sample effect is subject to the actual device.

getHeader12+

getHeader(): Array<WebHeader>

Obtains the information about the resource request header.

System capability: SystemCapability.Web.Webview.Core

Return value

Type Description
Array<WebHeader> Information about the resource request header.

Example

For the complete sample code, see onRequestStart.

getRequestUrl12+

getRequestUrl(): string

Obtains the URL of the resource request.

System capability: SystemCapability.Web.Webview.Core

Return value

Type Description
string URL of the resource request.

Example

For the complete sample code, see onRequestStart.

getRequestMethod12+

getRequestMethod(): string

Obtains the request method.

System capability: SystemCapability.Web.Webview.Core

Return value

Type Description
string Request method.

Example

For the complete sample code, see onRequestStart.

getReferrer12+

getReferrer(): string

Obtains the referrer.

System capability: SystemCapability.Web.Webview.Core

Return value

Type Description
string Obtained referrer.

Example

For the complete sample code, see onRequestStart.

isMainFrame12+

isMainFrame(): boolean

Checks whether the resource request is for the main frame.

System capability: SystemCapability.Web.Webview.Core

Return value

Type Description
boolean Whether the resource request is for the main frame. If the resource request is for the main frame, true is returned. Otherwise, false is returned.

Example

For the complete sample code, see onRequestStart.

hasGesture12+

hasGesture(): boolean

Checks whether the resource request is associated with a gesture (for example, a tap).

System capability: SystemCapability.Web.Webview.Core

Return value

Type Description
boolean Whether the resource request is associated with a gesture (for example, a tap). If the resource request is associated with a gesture, true is returned. Otherwise, false is returned.

Example

For the complete sample code, see onRequestStart.

getHttpBodyStream12+

getHttpBodyStream(): WebHttpBodyStream | null

Obtains the WebHttpBodyStream instance in this resource request.

System capability: SystemCapability.Web.Webview.Core

Return value

Type Description
WebHttpBodyStream | null WebHttpBodyStream instance in the resource request. If there is no WebHttpBodyStream instance, null is returned.

Example

For the complete sample code, see onRequestStart.

getRequestResourceType12+

getRequestResourceType(): WebResourceType

Obtains the resource type of this resource request.

System capability: SystemCapability.Web.Webview.Core

Return value

Type Description
WebResourceType Resource type of the resource request.

Example

For the complete sample code, see onRequestStart.

getFrameUrl12+

getFrameUrl(): string

Obtains the URL of the frame that triggers this request.

System capability: SystemCapability.Web.Webview.Core

Return value

Type Description
string URL of the frame that triggers the request.

Example

For the complete sample code, see onRequestStart.