DownloadTask.onHeadersReceived

Requires:
BaseKit≥2.0.1
Platforms:
iOSAndroid

Method signature
DownloadTask.onHeadersReceived(listener: )
Minimum SDK versions
iOSThingSmartBaseKitBizBundle
≥ 5.2.1
Androidcom.thingclips.smart:thingsmart-bizbundle-basekit
≥ 5.2.0

Description

Listen for HTTP Response Header events. Fires earlier than the request completion event

Parameters

ParameterTypeRequiredDescription
(params: ) => voidYesEvent listener callback function

Return Value

None

Examples

import { downloadFile } from '@ray-js/ray'

// Listen for response headers: first get the download task handle via ty.downloadFile, then register a headers listener on the handle.
const downloadTask = await downloadFile({
  url: "https://airtake-public-data-1254153901.cos.ap-shanghai.myqcloud.com/ttttestfile/test_video.mp4",
});

downloadTask.onHeadersReceived(e => {
  console.log(e);
});