Index: pkg/http/test/utils.dart |
diff --git a/pkg/http/test/utils.dart b/pkg/http/test/utils.dart |
index 3548df015d53e9946732ba29809142a8e777cf3a..9e0d01065f3460934b7e6ada819d74485b8fc8be 100644 |
--- a/pkg/http/test/utils.dart |
+++ b/pkg/http/test/utils.dart |
@@ -29,7 +29,7 @@ void startServer() { |
(request, response) { |
response.statusCode = 400; |
response.contentLength = 0; |
- response.outputStream.close(); |
+ closeResponse(request, response); |
}); |
_server.addRequestHandler((request) => request.path == '/loop', |
@@ -39,7 +39,7 @@ void startServer() { |
response.headers.set('location', |
serverUrl.resolve('/loop?${n + 1}').toString()); |
response.contentLength = 0; |
- response.outputStream.close(); |
+ closeResponse(request, response); |
}); |
_server.addRequestHandler((request) => request.path == '/redirect', |
@@ -47,7 +47,7 @@ void startServer() { |
response.statusCode = 302; |
response.headers.set('location', serverUrl.resolve('/').toString()); |
response.contentLength = 0; |
- response.outputStream.close(); |
+ closeResponse(request, response); |
}); |
_server.defaultRequestHandler = (request, response) { |
@@ -104,6 +104,15 @@ void stopServer() { |
_server = null; |
} |
+/// Closes [response] while ignoring the body of [request]. |
+/// |
+/// Due to issue 6984, it's necessary to drain the request body before closing |
+/// the response. |
+void closeResponse(HttpRequest request, HttpResponse response) { |
+ request.inputStream.onData = request.inputStream.read; |
+ request.inputStream.onClosed = response.outputStream.close; |
Bob Nystrom
2012/11/28 22:41:44
Will it cause any problems that we no longer synch
nweiz
2012/11/28 22:42:41
God, I hope not.
In seriousness, it was all being
|
+} |
+ |
/// A matcher that matches JSON that parses to a value that matches the inner |
/// matcher. |
Matcher parse(matcher) => new _Parse(matcher); |