Android Question OkHttpUtils2 - cancel download based on response header ContentType

Discussion in 'Android Questions' started by Pendrush, Jul 14, 2019 at 5:28 PM.

  1. Pendrush

    Pendrush Well-Known Member Licensed User

    Before B4A v9.30 I have used modified version of OkHttpUtils2 to cancel download based on header:
    Code:
    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.
     
  2. DonManfred

    DonManfred Expert Licensed 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
     
    Erel and Pendrush like this.
  3. Pendrush

    Pendrush Well-Known Member Licensed User

    Yep... I didn't even look Libraries folder.
    Thanks Don.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice