Download File Header problem
Summary
Download video partial content header not set
Steps to reproduce
public static async Task<byte[]> DownloadData(string url, Action<DownloadState> downloadState)
{
if (downloadState == null)
return await DownloadData(url);
using (var request = UnityWebRequest.Get(url))
{
var result = request.SendWebRequest();
ulong total = 0;
while (!request.isDone)
{
var progress = request.downloadProgress;
if (progress > 0)
{
total = (ulong)(request.downloadedBytes / progress);
downloadState.Invoke(new DownloadState(request.downloadedBytes, total, request.downloadProgress));
}
await UniTask.Delay(250);
}
downloadState.Invoke(new DownloadState(request.downloadedBytes, total, request.downloadProgress));
return string.IsNullOrEmpty(result.webRequest.error) ? result.webRequest.downloadHandler.data : null;
}
}
var file = DownloadData(url, state =>
{
var mbTotal = state.TotalBytes / 1024 / 1024;
print($"{mbTotal:F1} MB ({state.Progress} %)");
});
