Skip to content

Commit a27802e

Browse files
authored
flutter_tool: remove explicit length header in HTTP response (#119869)
This is already handled by pkg:shelf There is some subtlety with String here, since String.length might not align with the size in bytes over the wire, depending on the contents and the encoding Best to just let pkg:shelf handle it
1 parent c626460 commit a27802e

File tree

1 file changed

+0
-4
lines changed

1 file changed

+0
-4
lines changed

packages/flutter_tools/lib/src/isolated/devfs_web.dart

-4
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,6 @@ class WebAssetServer implements AssetReader {
387387
if (ifNoneMatch == etag) {
388388
return shelf.Response.notModified();
389389
}
390-
headers[HttpHeaders.contentLengthHeader] = bytes!.length.toString();
391390
headers[HttpHeaders.contentTypeHeader] = 'application/javascript';
392391
headers[HttpHeaders.etagHeader] = etag;
393392
return shelf.Response.ok(bytes, headers: headers);
@@ -400,7 +399,6 @@ class WebAssetServer implements AssetReader {
400399
if (ifNoneMatch == etag) {
401400
return shelf.Response.notModified();
402401
}
403-
headers[HttpHeaders.contentLengthHeader] = bytes!.length.toString();
404402
headers[HttpHeaders.contentTypeHeader] = 'application/json';
405403
headers[HttpHeaders.etagHeader] = etag;
406404
return shelf.Response.ok(bytes, headers: headers);
@@ -414,7 +412,6 @@ class WebAssetServer implements AssetReader {
414412
if (ifNoneMatch == etag) {
415413
return shelf.Response.notModified();
416414
}
417-
headers[HttpHeaders.contentLengthHeader] = bytes!.length.toString();
418415
headers[HttpHeaders.contentTypeHeader] = 'application/json';
419416
headers[HttpHeaders.etagHeader] = etag;
420417
return shelf.Response.ok(bytes, headers: headers);
@@ -504,7 +501,6 @@ class WebAssetServer implements AssetReader {
504501

505502
final Map<String, String> headers = <String, String>{
506503
HttpHeaders.contentTypeHeader: 'text/html',
507-
HttpHeaders.contentLengthHeader: indexHtml.content.length.toString(),
508504
};
509505
return shelf.Response.ok(indexHtml.content, headers: headers);
510506
}

0 commit comments

Comments
 (0)