DownloadTask.onHeadersReceived(listener: Function)

Requires:
BaseKit≥2.0.1
Platforms:
iOSAndroid

Description

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

Parameters

ParameterTypeRequiredDescription
YesEvent 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);
});