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
This commit is contained in:
Kevin Moore
2023-02-02 17:27:23 -08:00
committed by GitHub
parent c6264605d9
commit a27802e2db

View File

@@ -387,7 +387,6 @@ class WebAssetServer implements AssetReader {
if (ifNoneMatch == etag) {
return shelf.Response.notModified();
}
headers[HttpHeaders.contentLengthHeader] = bytes!.length.toString();
headers[HttpHeaders.contentTypeHeader] = 'application/javascript';
headers[HttpHeaders.etagHeader] = etag;
return shelf.Response.ok(bytes, headers: headers);
@@ -400,7 +399,6 @@ class WebAssetServer implements AssetReader {
if (ifNoneMatch == etag) {
return shelf.Response.notModified();
}
headers[HttpHeaders.contentLengthHeader] = bytes!.length.toString();
headers[HttpHeaders.contentTypeHeader] = 'application/json';
headers[HttpHeaders.etagHeader] = etag;
return shelf.Response.ok(bytes, headers: headers);
@@ -414,7 +412,6 @@ class WebAssetServer implements AssetReader {
if (ifNoneMatch == etag) {
return shelf.Response.notModified();
}
headers[HttpHeaders.contentLengthHeader] = bytes!.length.toString();
headers[HttpHeaders.contentTypeHeader] = 'application/json';
headers[HttpHeaders.etagHeader] = etag;
return shelf.Response.ok(bytes, headers: headers);
@@ -504,7 +501,6 @@ class WebAssetServer implements AssetReader {
final Map<String, String> headers = <String, String>{
HttpHeaders.contentTypeHeader: 'text/html',
HttpHeaders.contentLengthHeader: indexHtml.content.length.toString(),
};
return shelf.Response.ok(indexHtml.content, headers: headers);
}