Android Question OkHttpUtils2 - cancel download based on response header ContentType

Pendrush

Well-Known Member
Licensed User
Before B4A v9.30 I have used modified version of OkHttpUtils2 to cancel download based on header:
B4X:
Sub hc_ResponseSuccess (Response As OkHttpResponse, TaskId As Int)
    If Response.ContentType.Contains("audio") = True Then
        Response.Release
        CompleteJob(TaskId, False, "Audio inside header") 'cancel download
    Else       
        .......
    End If
End Sub
Now with OkHttpUtils2 v2.82 I don't have source code to make same modification inside HttpUtils2Service.bas.
Is there anyway to get Response.ContentType right after server return response and cancel download, without need to wait for JobDone event?
In my case JobDone will never fire (actual "file" is a audio stream without end). As "file" is actually audio stream, OkHttpUtils2 will download stream until device is out of space.
 
Top