openharmony 鸿蒙 arkts-basic-components-web-WebResourceResponse

2026-08-25 浏览 (1)

Class (WebResourceResponse)

Implements the WebResourceResponse object. For details about the sample code, see onHttpErrorReceive.

NOTE

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

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

  • The sample effect is subject to the actual device.

constructor

constructor()

Constructs a WebResourceResponse.

System capability: SystemCapability.Web.Webview.Core

getReasonMessage

getReasonMessage(): string

Obtains the status code description of the resource response.

System capability: SystemCapability.Web.Webview.Core

Return value

TypeDescription
stringStatus code description of the resource response.

getResponseCode

getResponseCode(): number

Obtains the status code of the resource response.

System capability: SystemCapability.Web.Webview.Core

Return value

TypeDescription
numberStatus code of the resource response.

getResponseData

getResponseData(): string

Obtains the data in the resource response.

System capability: SystemCapability.Web.Webview.Core

Return value

TypeDescription
stringData in the resource response.

getResponseEncoding

getResponseEncoding(): string

Obtains the encoding string of the resource response.

System capability: SystemCapability.Web.Webview.Core

Return value

TypeDescription
stringEncoding string of the resource response.

getResponseHeader

getResponseHeader() : Array<Header>

Obtains the resource response header.

System capability: SystemCapability.Web.Webview.Core

Return value

TypeDescription
Array<Header>Resource response header.

getResponseMimeType

getResponseMimeType(): string

Obtains the MIME type of the resource response.

System capability: SystemCapability.Web.Webview.Core

Return value

TypeDescription
stringMIME type of the resource response.

getResponseDataEx13+

getResponseDataEx(): string|number|ArrayBuffer|Resource|undefined

Obtains the data in the resource response. Multiple data types are supported.

System capability: SystemCapability.Web.Webview.Core

Return value

TypeDescription
string |number |ArrayBuffer |Resource |undefinedAn HTML string when the type is string; a file descriptor when the type is number; binary data when the type is ArrayBuffer; a $rawfile resource when the type is resource; or undefined if no data is available.

getResponseIsReady13+

getResponseIsReady(): boolean

Obtains whether the response data is ready.

System capability: SystemCapability.Web.Webview.Core

Return value

TypeDescription
booleantrue indicates that the response data is ready, and false indicates the opposite.

setResponseData9+

setResponseData(data: string |number |Resource |ArrayBuffer): void

Sets the data in the resource response.

System capability: SystemCapability.Web.Webview.Core

Parameters

NameTypeMandatoryDescription
datastring |number |Resource |ArrayBuffer11+YesResource response data to set. When set to a string, the value indicates a string in HTML format. When set to a number, the value indicates a file handle, which is closed by the system Web component. When set to a Resource object, the value indicates the file resources in the rawfile directory of the application. When set to an ArrayBuffer object, the value indicates the original binary data of a resource.

setResponseEncoding9+

setResponseEncoding(encoding: string): void

Sets the encoding string of the resource response.

System capability: SystemCapability.Web.Webview.Core

Parameters

NameTypeMandatoryDescription
encodingstringYesEncoding string to set.

setResponseMimeType9+

setResponseMimeType(mimeType: string): void

Sets the MIME type of the resource response.

System capability: SystemCapability.Web.Webview.Core

Parameters

NameTypeMandatoryDescription
mimeTypestringYesMIME type to set.

setReasonMessage9+

setReasonMessage(reason: string): void

Sets the status code description of the resource response.

System capability: SystemCapability.Web.Webview.Core

Parameters

NameTypeMandatoryDescription
reasonstringYesStatus code description to set.

setResponseHeader9+

setResponseHeader(header: Array<Header>): void

Sets the resource response header.

System capability: SystemCapability.Web.Webview.Core

Parameters

NameTypeMandatoryDescription
headerArray<Header>YesResource response header to set.

setResponseCode9+

setResponseCode(code: number): void

Sets the status code of the resource response.

System capability: SystemCapability.Web.Webview.Core

Parameters

NameTypeMandatoryDescription
codenumberYesStatus code to set. If the resource ends with an error, set the error code by referring to @ohos.web.netErrorList. Do not set the error code to ERR_IO_PENDING, which may block the synchronous XMLHttpRequest.

setResponseIsReady9+

setResponseIsReady(IsReady: boolean): void

Sets whether the resource response data is ready.

System capability: SystemCapability.Web.Webview.Core

Parameters

NameTypeMandatoryDescription
IsReadybooleanYesWhether the resource response data is ready.
The value true indicates that the resource response data is ready, and false indicates the opposite.
If the data is provided asynchronously, this parameter must be explicitly set to false. If this parameter is set to an invalid value, for example, null or undefined, or is not set, the data is considered ready.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 arkts-apis-webview-WebviewController

openharmony 鸿蒙 arkts-apis-webview-t

openharmony 鸿蒙 arkts-apis-webview

openharmony 鸿蒙 capi-arkweb-type-h

openharmony 鸿蒙 arkts-basic-components-web-FullScreenExitHandler

openharmony 鸿蒙 arkts-apis-webview-WebDownloadManager

openharmony 鸿蒙 arkts-basic-components-web-VerifyPinHandler

openharmony 鸿蒙 capi-web-arkweb-webmessage8h

openharmony 鸿蒙 arkts-apis-webview-NativeMediaPlayerHandler

openharmony 鸿蒙 capi-web-arkweb-proxymethodwithresult

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/ET104IKP