Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change order to allow to override ifNoneMatchHeader #463

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion flutter_cache_manager/lib/src/result/file_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}
8 changes: 5 additions & 3 deletions flutter_cache_manager/lib/src/web/web_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,6 @@ class WebHelper {
Future<FileServiceResponse> _download(
CacheObject cacheObject, Map<String, String>? authHeaders) {
final headers = <String, String>{};
if (authHeaders != null) {
headers.addAll(authHeaders);
}

final etag = cacheObject.eTag;

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

if (authHeaders != null) {
headers.addAll(authHeaders);
}

return fileFetcher.get(cacheObject.url, headers: headers);
}

Expand Down Expand Up @@ -152,6 +153,7 @@ class WebHelper {
FileSource.Online,
newCacheObject.validTill,
newCacheObject.url,
statusCode: response.statusCode,
);
}

Expand Down