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

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: Created 3 years, 6 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
« test/http_body_test.dart ('K') | « 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
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}) {
53 HttpServer.bind("127.0.0.1", 0).then((server) { 53 HttpServer.bind("localhost", 0).then((server) {
54 server.listen((request) { 54 server.listen((request) {
55 String boundary = request.headers.contentType.parameters['boundary']; 55 String boundary = request.headers.contentType.parameters['boundary'];
56 request 56 request
57 .transform(new MimeMultipartTransformer(boundary)) 57 .transform(new MimeMultipartTransformer(boundary))
58 .map((part) => HttpMultipartFormData.parse( 58 .map((part) => HttpMultipartFormData.parse(
59 part, defaultEncoding: defaultEncoding)) 59 part, defaultEncoding: defaultEncoding))
60 .map((multipart) { 60 .map((multipart) {
61 var future; 61 var future;
62 if (multipart.isText) { 62 if (multipart.isText) {
63 future = multipart.join(); 63 future = multipart.join();
(...skipping 15 matching lines...) Expand all
79 }); 79 });
80 }) 80 })
81 .toList() 81 .toList()
82 .then(Future.wait) 82 .then(Future.wait)
83 .then((fields) { 83 .then((fields) {
84 expect(fields, equals(expectedFields)); 84 expect(fields, equals(expectedFields));
85 request.response.close().then((_) => server.close()); 85 request.response.close().then((_) => server.close());
86 }); 86 });
87 }); 87 });
88 var client = new HttpClient(); 88 var client = new HttpClient();
89 client.post('127.0.0.1', server.port, '/') 89 client.post('localhost', server.port, '/')
90 .then((request) { 90 .then((request) {
91 request.headers.set('content-type', 91 request.headers.set('content-type',
92 'multipart/form-data; boundary=$boundary'); 92 'multipart/form-data; boundary=$boundary');
93 request.add(message); 93 request.add(message);
94 return request.close(); 94 return request.close();
95 }) 95 })
96 .then((response) { 96 .then((response) {
97 client.close(); 97 client.close();
98 }); 98 });
99 }); 99 });
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 'multipart/form-data', 248 'multipart/form-data',
249 '----WebKitFormBoundaryfe0EzV1aNysD1bPh', 249 '----WebKitFormBoundaryfe0EzV1aNysD1bPh',
250 [new FormField('name', 'øv')]); 250 [new FormField('name', 'øv')]);
251 } 251 }
252 252
253 253
254 void main() { 254 void main() {
255 testEmptyPostData(); 255 testEmptyPostData();
256 testPostData(); 256 testPostData();
257 } 257 }
OLDNEW
« test/http_body_test.dart ('K') | « test/http_body_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698