Skip to content

Commit

Permalink
Explicit HEAD support in fake storage server. (#7600)
Browse files Browse the repository at this point in the history
  • Loading branch information
isoos authored Mar 27, 2024
1 parent 58b2f0a commit 60583d9
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion app/lib/fake/server/fake_storage_server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,23 @@ class FakeStorageServer {
}

Future<Response> _handler(Request request) async {
if (request.method == 'GET') {
if (request.method == 'HEAD') {
_logger.info('Requested: ${request.requestedUri.path}');
final segments = request.requestedUri.pathSegments;
if (segments.length < 2) {
return Response.notFound('404 Not Found');
}
final bucketName = segments.first;
final objectName = segments.skip(1).join('/');
final bucket = _storage.bucket(bucketName);
final exists = await bucket.tryInfo(objectName);
if (exists == null) {
return Response.notFound('404 Not Found');
}
final contentType = lookupMimeType(objectName);
return Response.ok(<int>[],
headers: {if (contentType != null) 'Content-Type': contentType});
} else if (request.method == 'GET') {
_logger.info('Requested: ${request.requestedUri.path}');
final segments = request.requestedUri.pathSegments;
if (segments.length < 2) {
Expand Down

0 comments on commit 60583d9

Please sign in to comment.