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

Side by Side Diff: pkg/http/test/request_test.dart

Issue 11411121: Generate an error for active connections when the HTTP client is shutdown (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed long line 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/pkg.status » ('j') | sdk/lib/io/http.dart » ('J')
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 request_test; 5 library request_test;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 8
9 import '../../unittest/lib/unittest.dart'; 9 import '../../unittest/lib/unittest.dart';
10 import '../lib/http.dart' as http; 10 import '../lib/http.dart' as http;
11 import '../lib/src/utils.dart'; 11 import '../lib/src/utils.dart';
12 import 'utils.dart'; 12 import 'utils.dart';
13 13
14 void main() { 14 void main() {
15 test('.send', () { 15 test('.send', () {
16 print("This test is known to be flaky, please ignore "
17 "(debug prints below added by sgjesse@)");
18 print(".send test starting server...");
19 startServer(); 16 startServer();
20 print(".send test server running");
21 17
22 var request = new http.Request('POST', serverUrl); 18 var request = new http.Request('POST', serverUrl);
23 request.body = "hello"; 19 request.body = "hello";
24 var future = request.send().chain((response) { 20 var future = request.send().chain((response) {
25 print(".send test response received");
26 expect(response.statusCode, equals(200)); 21 expect(response.statusCode, equals(200));
27 return consumeInputStream(response.stream); 22 return consumeInputStream(response.stream);
28 }).transform((bytes) => new String.fromCharCodes(bytes)); 23 }).transform((bytes) => new String.fromCharCodes(bytes));
29 future.onComplete((_) { 24 future.onComplete((_) {
30 print(".send test stopping server...");
31 stopServer(); 25 stopServer();
32 print(".send test server stopped");
33 }); 26 });
34 27
35 expect(future, completion(parse(equals({ 28 expect(future, completion(parse(equals({
36 'method': 'POST', 29 'method': 'POST',
37 'path': '/', 30 'path': '/',
38 'headers': { 31 'headers': {
39 'content-type': ['text/plain; charset=UTF-8'], 32 'content-type': ['text/plain; charset=UTF-8'],
40 'content-length': ['5'] 33 'content-length': ['5']
41 }, 34 },
42 'body': 'hello' 35 'body': 'hello'
43 })))); 36 }))));
44 print(".send test started");
45 }); 37 });
46 38
47 group('#contentLength', () { 39 group('#contentLength', () {
48 test('is computed from bodyBytes', () { 40 test('is computed from bodyBytes', () {
49 var request = new http.Request('POST', dummyUrl); 41 var request = new http.Request('POST', dummyUrl);
50 request.bodyBytes = [1, 2, 3, 4, 5]; 42 request.bodyBytes = [1, 2, 3, 4, 5];
51 expect(request.contentLength, equals(5)); 43 expect(request.contentLength, equals(5));
52 request.bodyBytes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; 44 request.bodyBytes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
53 expect(request.contentLength, equals(10)); 45 expect(request.contentLength, equals(10));
54 }); 46 });
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 }); 335 });
344 336
345 test("can't be called twice", () { 337 test("can't be called twice", () {
346 var request = new http.Request('POST', dummyUrl); 338 var request = new http.Request('POST', dummyUrl);
347 request.finalize(); 339 request.finalize();
348 expect(request.finalize, throwsStateError); 340 expect(request.finalize, throwsStateError);
349 }); 341 });
350 }); 342 });
351 } 343 }
352 344
OLDNEW
« no previous file with comments | « no previous file | pkg/pkg.status » ('j') | sdk/lib/io/http.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698