Skip to content
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
1 change: 1 addition & 0 deletions http_cache_core/lib/src/model/cache/cache_control.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class CacheControl {
other.add(attribute);
}
}
scanner.scan(whitespace);
}

headerValues ??= [];
Expand Down
23 changes: 23 additions & 0 deletions http_cache_core/test/cache_control_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,29 @@ void main() {
expect(cacheControl1, equals(cacheControl3));
});

test('headers with and without optional whitespace', () {
final cacheControl1 = CacheControl(
maxAge: 1,
noCache: true,
noStore: true,
other: ['unknown', 'unknown2=2'],
privacy: 'public',
maxStale: 2,
minFresh: 3,
mustRevalidate: true,
);

final cacheControl2 = CacheControl.fromHeader([
'max-age=1 , no-store, no-cache, public,unknown , unknown2=2 , max-stale=2,min-fresh=3,must-revalidate',
]);

expect(cacheControl1, equals(cacheControl2));

// Redo test with toHeader()
final cacheControl3 = CacheControl.fromHeader([cacheControl2.toHeader()]);
expect(cacheControl1, equals(cacheControl3));
});

test('headers splitted', () {
final cacheControl1 = CacheControl(
maxAge: 1,
Expand Down