mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 00:09:49 +00:00
[ddc] Update content-length to not be negative
The null safety migration changed the 'content-length' from null to -1 but a separate change at the same time disallowed negative values. Now returning what the 'content-length' would be if the request was a GET. Fixes: https://github.com/dart-lang/sdk/issues/49483 Change-Id: I2ba3ce1fb604c0fac50f354f56b3d29de6465caa Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/252005 Reviewed-by: Sigmund Cherem <sigmund@google.com> Commit-Queue: Nicholas Shahan <nshahan@google.com>
This commit is contained in:
parent
0add39a68e
commit
3526954466
|
@ -936,22 +936,15 @@ class TestAssetServer {
|
|||
try {
|
||||
var entity = fileSystem.entityForUri(uri);
|
||||
if (await entity.existsAsyncIfPossible()) {
|
||||
if (request.method == 'HEAD') {
|
||||
var headers = {
|
||||
'content-length': '-1',
|
||||
...request.headers,
|
||||
};
|
||||
return Response.ok(null, headers: headers);
|
||||
}
|
||||
|
||||
if (request.method == 'GET') {
|
||||
if (request.method == 'HEAD' || request.method == 'GET') {
|
||||
// 'readAsBytes'
|
||||
var contents = await entity.readAsBytesAsyncIfPossible();
|
||||
var headers = {
|
||||
'content-length': '${contents.length}',
|
||||
...request.headers,
|
||||
};
|
||||
return Response.ok(contents, headers: headers);
|
||||
return Response.ok(request.method == 'GET' ? contents : null,
|
||||
headers: headers);
|
||||
}
|
||||
}
|
||||
return Response.notFound(path);
|
||||
|
|
Loading…
Reference in a new issue