llfbandit / dio_cache_interceptor

Dio HTTP cache interceptor with multiple stores respecting HTTP directives (ETag, Last-Modified, Cache-Control) with options.
https://pub.dev/packages/dio_cache_interceptor
120 stars 70 forks source link

The interceptor tries to parse using DateTime the expires Header even if the value is "-1" #128

Closed mablds closed 1 year ago

mablds commented 1 year ago

Running our Flutter application with your lib we noticed that there's one request that the cache has expired and it's header expires comes with the value "-1". When this happens, the lib throws an Unhandled exception:

Captura de Tela 2023-06-16 às 14 15 54

llfbandit commented 1 year ago

This exception is expected since the date coming from expires header is not a date. If you look closely, this should be handled in CacheResponse: https://github.com/llfbandit/dio_cache_interceptor/blob/919077108adf4857caa73d85b999178d2b9b6577/dio_cache_interceptor/lib/src/model/cache_response.dart#L214-L219

This is just a guess since I don't have enough information to make a clear diagnotic.