mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[flutter_tools] ensure etag headers are ascii (#55704)
This commit is contained in:
parent
34b8f830b8
commit
2aa9016652
@ -350,7 +350,8 @@ class WebAssetServer implements AssetReader {
|
||||
|
||||
// For real files, use a serialized file stat plus path as a revision.
|
||||
// This allows us to update between canvaskit and non-canvaskit SDKs.
|
||||
final String etag = file.lastModifiedSync().toIso8601String() + file.path;
|
||||
final String etag = file.lastModifiedSync().toIso8601String()
|
||||
+ Uri.encodeComponent(file.path);
|
||||
if (ifNoneMatch == etag) {
|
||||
return shelf.Response.notModified();
|
||||
}
|
||||
|
||||
@ -324,6 +324,18 @@ void main() {
|
||||
expect((await response.read().toList()).first, source.readAsBytesSync());
|
||||
}));
|
||||
|
||||
test('serves valid etag header for asset files with non-ascii chracters', () => testbed.run(() async {
|
||||
globals.fs.file(globals.fs.path.join('build', 'flutter_assets', 'fooπ'))
|
||||
..createSync(recursive: true)
|
||||
..writeAsBytesSync(<int>[1, 2, 3]);
|
||||
|
||||
final Response response = await webAssetServer
|
||||
.handleRequest(Request('GET', Uri.parse('http://foobar/assets/fooπ')));
|
||||
final String etag = response.headers[HttpHeaders.etagHeader];
|
||||
|
||||
expect(etag.runes, everyElement(predicate((int char) => char < 255)));
|
||||
}));
|
||||
|
||||
test('handles serving missing asset file', () => testbed.run(() async {
|
||||
final Response response = await webAssetServer
|
||||
.handleRequest(Request('GET', Uri.parse('http://foobar/assets/foo')));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user