diff --git a/flutter_cache_manager/lib/src/result/file_info.dart b/flutter_cache_manager/lib/src/result/file_info.dart index 1023e3ef..ae874830 100644 --- a/flutter_cache_manager/lib/src/result/file_info.dart +++ b/flutter_cache_manager/lib/src/result/file_info.dart @@ -12,7 +12,8 @@ enum FileSource { NA, Cache, Online } /// FileInfo contains the fetch File next to some info on the validity and /// the origin of the file. class FileInfo extends FileResponse { - const FileInfo(this.file, this.source, this.validTill, String originalUrl) + const FileInfo(this.file, this.source, this.validTill, String originalUrl, + {this.statusCode = 200}) : super(originalUrl); /// Fetched file @@ -24,4 +25,6 @@ class FileInfo extends FileResponse { /// Validity date of the file. After this date the validity is not guaranteed /// and the CacheManager will try to update the file. final DateTime validTill; + + final int statusCode; } diff --git a/flutter_cache_manager/lib/src/web/web_helper.dart b/flutter_cache_manager/lib/src/web/web_helper.dart index 81b0e710..20685484 100644 --- a/flutter_cache_manager/lib/src/web/web_helper.dart +++ b/flutter_cache_manager/lib/src/web/web_helper.dart @@ -100,9 +100,6 @@ class WebHelper { Future _download( CacheObject cacheObject, Map? authHeaders) { final headers = {}; - if (authHeaders != null) { - headers.addAll(authHeaders); - } final etag = cacheObject.eTag; @@ -111,6 +108,10 @@ class WebHelper { headers[HttpHeaders.ifNoneMatchHeader] = etag; } + if (authHeaders != null) { + headers.addAll(authHeaders); + } + return fileFetcher.get(cacheObject.url, headers: headers); } @@ -152,6 +153,7 @@ class WebHelper { FileSource.Online, newCacheObject.validTill, newCacheObject.url, + statusCode: response.statusCode, ); }