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

Side by Side Diff: utils/tests/pub/curl_client_test.dart

Issue 12021008: Use the dart:async Stream API thoroughly in Pub. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « utils/pub/utils.dart ('k') | utils/tests/pub/oauth2_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library curl_client_test; 5 library curl_client_test;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 import 'dart:isolate'; 8 import 'dart:isolate';
9 import 'dart:json' as json; 9 import 'dart:json' as json;
10 import 'dart:uri'; 10 import 'dart:uri';
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 80
81 _server.addRequestHandler((request) => request.path == '/redirect', 81 _server.addRequestHandler((request) => request.path == '/redirect',
82 (request, response) { 82 (request, response) {
83 response.statusCode = 302; 83 response.statusCode = 302;
84 response.headers.set('location', serverUrl.resolve('/').toString()); 84 response.headers.set('location', serverUrl.resolve('/').toString());
85 response.contentLength = 0; 85 response.contentLength = 0;
86 response.outputStream.close(); 86 response.outputStream.close();
87 }); 87 });
88 88
89 _server.defaultRequestHandler = (request, response) { 89 _server.defaultRequestHandler = (request, response) {
90 consumeInputStream(request.inputStream).then((requestBodyBytes) { 90 wrapInputStream(request.inputStream).toBytes().then((requestBodyBytes) {
91 response.statusCode = 200; 91 response.statusCode = 200;
92 response.headers.contentType = new ContentType("application", "json"); 92 response.headers.contentType = new ContentType("application", "json");
93 93
94 var requestBody; 94 var requestBody;
95 if (requestBodyBytes.isEmpty) { 95 if (requestBodyBytes.isEmpty) {
96 requestBody = null; 96 requestBody = null;
97 } else if (request.headers.contentType.charset != null) { 97 } else if (request.headers.contentType.charset != null) {
98 var encoding = requiredEncodingForCharset( 98 var encoding = requiredEncodingForCharset(
99 request.headers.contentType.charset); 99 request.headers.contentType.charset);
100 requestBody = decodeString(requestBodyBytes, encoding); 100 requestBody = decodeString(requestBodyBytes, encoding);
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 test('without following redirects', () { 451 test('without following redirects', () {
452 var request = new http.Request('GET', serverUrl.resolve('/redirect')); 452 var request = new http.Request('GET', serverUrl.resolve('/redirect'));
453 request.followRedirects = false; 453 request.followRedirects = false;
454 expect(new CurlClient().send(request).then(http.Response.fromStream) 454 expect(new CurlClient().send(request).then(http.Response.fromStream)
455 .then((response) { 455 .then((response) {
456 expect(response.statusCode, equals(302)); 456 expect(response.statusCode, equals(302));
457 expect(response.isRedirect, true); 457 expect(response.isRedirect, true);
458 }), completes); 458 }), completes);
459 }); 459 });
460 } 460 }
OLDNEW
« no previous file with comments | « utils/pub/utils.dart ('k') | utils/tests/pub/oauth2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698