Search code examples
androidandroid-ion

Downloading - get a callback when received all the request headers


I use ion library for downloading files in my app. I want to read the response headers, check a particular header and either cancel or continue the download. Of course I can execute the HEAD query, check the header, and then execute the GET query. But I want to execute only one request.

Is there a way to get a callback when received all the headers, handle them and either continue or cancel the download?


Solution

  • Use the onHeaders callback.

    .onHeaders(...)
    

    https://github.com/koush/ion/blob/master/ion/src/com/koushikdutta/ion/builder/RequestBuilder.java#L186