Android Question OkHttpUtils2 - cancel download based on response header ContentType

Pendrush

Well-Known Member
Licensed User
Longtime 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.
 

DonManfred

Expert
Licensed User
Longtime User
OkHttpUtils2.b4xlib
is a b4xlib. Rename it to OkHttpUtils2.b4xlib.zip, extract the source modules, edit them as needed, put the edited source back to the OkHttpUtils2.b4xlib.zip
rename the OkHttpUtils2.b4xlib.zip to OkHttpUtils2.b4xlib
 
Upvote 0
Top