Cache bugfixes

This commit is contained in:
Tobe O 2018-04-01 22:50:13 -04:00
parent 4f3f0c1e58
commit e3710d018a
3 changed files with 10 additions and 2 deletions

View file

@ -0,0 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="main.dart" type="DartCommandLineRunConfigurationType" factoryName="Dart Command Line Application" singleton="true" nameIsGenerated="true">
<option name="filePath" value="$PROJECT_DIR$/example/main.dart" />
<option name="workingDirectory" value="$PROJECT_DIR$" />
<method />
</configuration>
</component>

View file

@ -3,7 +3,7 @@ import 'package:angel_framework/angel_framework.dart';
import 'package:glob/glob.dart'; import 'package:glob/glob.dart';
main() async { main() async {
var app = new Angel(); var app = new Angel()..lazyParseBodies = true;
// Cache a glob // Cache a glob
var cache = new ResponseCache() var cache = new ResponseCache()

View file

@ -67,6 +67,7 @@ class ResponseCache {
Future<bool> handleRequest(RequestContext req, ResponseContext res) async { Future<bool> handleRequest(RequestContext req, ResponseContext res) async {
if (!await ifModifiedSince(req, res)) return false; if (!await ifModifiedSince(req, res)) return false;
if (req.method != 'GET' && req.method != 'HEAD') return true; if (req.method != 'GET' && req.method != 'HEAD') return true;
if (!res.isOpen) return true;
// Check if there is a cache entry. // Check if there is a cache entry.
// //
@ -130,7 +131,7 @@ class ResponseCache {
new Map.from(res.headers), res.buffer.toBytes(), now); new Map.from(res.headers), res.buffer.toBytes(), now);
}); });
_setCachedHeaders(now, req, res); // _setCachedHeaders(now, req, res);
} }
} }