From e3710d018ac02b4b9f535533935dcfd9a0b4af27 Mon Sep 17 00:00:00 2001 From: Tobe O Date: Sun, 1 Apr 2018 22:50:13 -0400 Subject: [PATCH] Cache bugfixes --- .idea/runConfigurations/main_dart.xml | 7 +++++++ example/main.dart | 2 +- lib/src/cache.dart | 3 ++- 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 .idea/runConfigurations/main_dart.xml diff --git a/.idea/runConfigurations/main_dart.xml b/.idea/runConfigurations/main_dart.xml new file mode 100644 index 00000000..750f7262 --- /dev/null +++ b/.idea/runConfigurations/main_dart.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/example/main.dart b/example/main.dart index f40642ee..bdf8c5a6 100644 --- a/example/main.dart +++ b/example/main.dart @@ -3,7 +3,7 @@ import 'package:angel_framework/angel_framework.dart'; import 'package:glob/glob.dart'; main() async { - var app = new Angel(); + var app = new Angel()..lazyParseBodies = true; // Cache a glob var cache = new ResponseCache() diff --git a/lib/src/cache.dart b/lib/src/cache.dart index 5688a84a..d048c67e 100644 --- a/lib/src/cache.dart +++ b/lib/src/cache.dart @@ -67,6 +67,7 @@ class ResponseCache { Future handleRequest(RequestContext req, ResponseContext res) async { if (!await ifModifiedSince(req, res)) return false; if (req.method != 'GET' && req.method != 'HEAD') return true; + if (!res.isOpen) return true; // Check if there is a cache entry. // @@ -130,7 +131,7 @@ class ResponseCache { new Map.from(res.headers), res.buffer.toBytes(), now); }); - _setCachedHeaders(now, req, res); + // _setCachedHeaders(now, req, res); } }