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

Unified Diff: utils/tests/pub/pub_lish_test.dart

Issue 12211052: Drain HTTP request input streams before responding. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 months 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 | « utils/pub/io.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/tests/pub/pub_lish_test.dart
diff --git a/utils/tests/pub/pub_lish_test.dart b/utils/tests/pub/pub_lish_test.dart
index 7101d91c0ade7b3e73deaf36ac895980d3b9e3ea..482b6165658c308537b012d1eabe00be4c7b59d1 100644
--- a/utils/tests/pub/pub_lish_test.dart
+++ b/utils/tests/pub/pub_lish_test.dart
@@ -38,7 +38,9 @@ void handleUpload(ScheduledServer server) {
server.handle('POST', '/upload', (request, response) {
// TODO(nweiz): Once a multipart/form-data parser in Dart exists, validate
// that the request body is correctly formatted. See issue 6952.
- return server.url.then((url) {
+ return drainInputStream(request.inputStream).then((_) {
+ return server.url;
nweiz 2013/02/06 20:47:05 Style nit: I'd probably make this a "=>"-style lam
Bob Nystrom 2013/02/06 20:50:40 I did that first, but then the following then() do
+ }).then((url) {
response.statusCode = 302;
response.headers.set('location', url.resolve('/create').toString());
response.outputStream.close();
@@ -260,11 +262,13 @@ main() {
handleUploadForm(server);
server.handle('POST', '/upload', (request, response) {
- response.statusCode = 400;
- response.headers.contentType = new ContentType('application', 'xml');
- response.outputStream.writeString('<Error><Message>Your request sucked.'
- '</Message></Error>');
- response.outputStream.close();
+ return drainInputStream(request.inputStream).then((_) {
+ response.statusCode = 400;
+ response.headers.contentType = new ContentType('application', 'xml');
+ response.outputStream.writeString('<Error><Message>Your request sucked.'
+ '</Message></Error>');
+ response.outputStream.close();
+ });
});
// TODO(nweiz): This should use the server's error message once the client
@@ -282,8 +286,10 @@ main() {
handleUploadForm(server);
server.handle('POST', '/upload', (request, response) {
- // don't set the location header
- response.outputStream.close();
+ return drainInputStream(request.inputStream).then((_) {
+ // Don't set the location header.
+ response.outputStream.close();
+ });
});
expectLater(pub.nextErrLine(), equals('Failed to upload the package.'));
« no previous file with comments | « utils/pub/io.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698