Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(739)

Unified Diff: pkg/http/test/utils.dart

Issue 11348285: Work around issue 6984. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | utils/pub/io.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « no previous file | utils/pub/io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698