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

Side by Side Diff: test/http_multipart_test.dart

Issue 2945343002: Change '127.0.0.1' to 'localhost' to support both IPv4 and IPv6 envs. (Closed)
Patch Set: address comments Created 3 years, 5 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
« no previous file with comments | « test/http_body_test.dart ('k') | no next file » | 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 import "package:http_server/http_server.dart"; 5 import "package:http_server/http_server.dart";
6 import "package:mime/mime.dart"; 6 import "package:mime/mime.dart";
7 import "package:unittest/unittest.dart"; 7 import "package:unittest/unittest.dart";
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:io'; 9 import 'dart:io';
10 import 'dart:convert'; 10 import 'dart:convert';
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 String toString() { 43 String toString() {
44 return "FormField('$name', '$value', '$contentType', '$filename')"; 44 return "FormField('$name', '$value', '$contentType', '$filename')";
45 } 45 }
46 } 46 }
47 47
48 void postDataTest(List<int> message, 48 void postDataTest(List<int> message,
49 String contentType, 49 String contentType,
50 String boundary, 50 String boundary,
51 List<FormField> expectedFields, 51 List<FormField> expectedFields,
52 {defaultEncoding: LATIN1}) { 52 {defaultEncoding: LATIN1}) async {
53 HttpServer.bind("127.0.0.1", 0).then((server) { 53 var addr = (await InternetAddress.lookup("localhost"))[0];
54 HttpServer.bind(addr, 0).then((server) {
54 server.listen((request) { 55 server.listen((request) {
55 String boundary = request.headers.contentType.parameters['boundary']; 56 String boundary = request.headers.contentType.parameters['boundary'];
56 request 57 request
57 .transform(new MimeMultipartTransformer(boundary)) 58 .transform(new MimeMultipartTransformer(boundary))
58 .map((part) => HttpMultipartFormData.parse( 59 .map((part) => HttpMultipartFormData.parse(
59 part, defaultEncoding: defaultEncoding)) 60 part, defaultEncoding: defaultEncoding))
60 .map((multipart) { 61 .map((multipart) {
61 var future; 62 var future;
62 if (multipart.isText) { 63 if (multipart.isText) {
63 future = multipart.join(); 64 future = multipart.join();
(...skipping 15 matching lines...) Expand all
79 }); 80 });
80 }) 81 })
81 .toList() 82 .toList()
82 .then(Future.wait) 83 .then(Future.wait)
83 .then((fields) { 84 .then((fields) {
84 expect(fields, equals(expectedFields)); 85 expect(fields, equals(expectedFields));
85 request.response.close().then((_) => server.close()); 86 request.response.close().then((_) => server.close());
86 }); 87 });
87 }); 88 });
88 var client = new HttpClient(); 89 var client = new HttpClient();
89 client.post('127.0.0.1', server.port, '/') 90 client.post('localhost', server.port, '/')
90 .then((request) { 91 .then((request) {
91 request.headers.set('content-type', 92 request.headers.set('content-type',
92 'multipart/form-data; boundary=$boundary'); 93 'multipart/form-data; boundary=$boundary');
93 request.add(message); 94 request.add(message);
94 return request.close(); 95 return request.close();
95 }) 96 })
96 .then((response) { 97 .then((response) {
97 client.close(); 98 client.close();
98 }); 99 });
99 }); 100 });
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 'multipart/form-data', 249 'multipart/form-data',
249 '----WebKitFormBoundaryfe0EzV1aNysD1bPh', 250 '----WebKitFormBoundaryfe0EzV1aNysD1bPh',
250 [new FormField('name', 'øv')]); 251 [new FormField('name', 'øv')]);
251 } 252 }
252 253
253 254
254 void main() { 255 void main() {
255 testEmptyPostData(); 256 testEmptyPostData();
256 testPostData(); 257 testPostData();
257 } 258 }
OLDNEW
« no previous file with comments | « test/http_body_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698