Sub hc_ResponseSuccess (Response As OkHttpResponse, TaskId As Int)
Dim j As HttpJob = TaskIdToJob.Get(TaskId)
If j.Tag Is JobTag Then
Dim cs As CountingOutputStream
cs.Initialize(File.OpenOutput(TempFolder, TaskId, False))
Dim jt As JobTag = j.Tag
jt.CountingStream = cs
jt.Total = Response.ContentLength
If jt.Data.url = "" Then
Log("Job cancelled before downloaded started")
cs.Close
End If
Response.GetAsynchronously("response", cs , _
True, TaskId)
'**************************************
Else
Response.GetAsynchronously("response", File.OpenOutput(TempFolder, TaskId, False), _
True, TaskId)
End Sub