Skip to content

Commit 0f05da6

Browse files
authored
Merge pull request #463 from binSaed/feature/override--ifNoneMatchHeader
change order to allow to override ifNoneMatchHeader
2 parents d6ddc33 + 6be3abf commit 0f05da6

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

flutter_cache_manager/lib/src/result/file_info.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ enum FileSource { NA, Cache, Online }
1212
/// FileInfo contains the fetch File next to some info on the validity and
1313
/// the origin of the file.
1414
class FileInfo extends FileResponse {
15-
const FileInfo(this.file, this.source, this.validTill, String originalUrl)
15+
const FileInfo(this.file, this.source, this.validTill, String originalUrl,
16+
{this.statusCode = 200})
1617
: super(originalUrl);
1718

1819
/// Fetched file
@@ -24,4 +25,6 @@ class FileInfo extends FileResponse {
2425
/// Validity date of the file. After this date the validity is not guaranteed
2526
/// and the CacheManager will try to update the file.
2627
final DateTime validTill;
28+
29+
final int statusCode;
2730
}

flutter_cache_manager/lib/src/web/web_helper.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,6 @@ class WebHelper {
100100
Future<FileServiceResponse> _download(
101101
CacheObject cacheObject, Map<String, String>? authHeaders) {
102102
final headers = <String, String>{};
103-
if (authHeaders != null) {
104-
headers.addAll(authHeaders);
105-
}
106103

107104
final etag = cacheObject.eTag;
108105

@@ -111,6 +108,10 @@ class WebHelper {
111108
headers[HttpHeaders.ifNoneMatchHeader] = etag;
112109
}
113110

111+
if (authHeaders != null) {
112+
headers.addAll(authHeaders);
113+
}
114+
114115
return fileFetcher.get(cacheObject.url, headers: headers);
115116
}
116117

@@ -152,6 +153,7 @@ class WebHelper {
152153
FileSource.Online,
153154
newCacheObject.validTill,
154155
newCacheObject.url,
156+
statusCode: response.statusCode,
155157
);
156158
}
157159

0 commit comments

Comments
 (0)