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

Side by Side Diff: tests/standalone/io/http_body_test.dart

Issue 14660009: Implement support for application/x-www-form-urlencoded' form data in HttpBodyHandler. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Cleanup Created 7 years, 7 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 | « sdk/lib/io/http_utils.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 'dart:io'; 5 import 'dart:io';
6 import 'dart:utf'; 6 import 'dart:utf';
7 7
8 import 'package:expect/expect.dart'; 8 import 'package:expect/expect.dart';
9 9
10 void testHttpClientResponseBody() { 10 void testHttpClientResponseBody() {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 Expect.equals(body.contentType.mimeType, "application/json"); 106 Expect.equals(body.contentType.mimeType, "application/json");
107 Expect.mapEquals(expectedBody, body.body); 107 Expect.mapEquals(expectedBody, body.body);
108 break; 108 break;
109 109
110 case "binary": 110 case "binary":
111 Expect.equals(body.contentType, null); 111 Expect.equals(body.contentType, null);
112 Expect.listEquals(expectedBody, body.body); 112 Expect.listEquals(expectedBody, body.body);
113 break; 113 break;
114 114
115 case "form": 115 case "form":
116 Expect.equals(body.contentType.mimeType, 'multipart/form-data'); 116 var mimeType = body.contentType.mimeType;
117 Expect.isTrue(
118 mimeType == 'multipart/form-data' ||
119 mimeType == 'application/x-www-form-urlencoded');
117 Expect.setEquals(expectedBody.keys.toSet(), 120 Expect.setEquals(expectedBody.keys.toSet(),
118 body.body.keys.toSet()); 121 body.body.keys.toSet());
119 for (var key in expectedBody.keys) { 122 for (var key in expectedBody.keys) {
120 if (body.body[key] is HttpBodyFileUpload) { 123 if (body.body[key] is HttpBodyFileUpload) {
121 Expect.equals(expectedBody[key]['contentType'], 124 Expect.equals(expectedBody[key]['contentType'],
122 body.body[key].contentType.toString()); 125 body.body[key].contentType.toString());
123 Expect.equals(expectedBody[key]['filename'], 126 Expect.equals(expectedBody[key]['filename'],
124 body.body[key].filename); 127 body.body[key].filename);
125 if (body.body[key].content is String) { 128 if (body.body[key].content is String) {
126 Expect.equals(expectedBody[key]['content'], 129 Expect.equals(expectedBody[key]['content'],
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 --AaB03x\r 236 --AaB03x\r
234 Content-Disposition: form-data; name="files"; filename="myfile"\r 237 Content-Disposition: form-data; name="files"; filename="myfile"\r
235 Content-Type: application/json\r 238 Content-Type: application/json\r
236 \r 239 \r
237 File content\r 240 File content\r
238 --AaB03x--\r\n'''.codeUnits, 241 --AaB03x--\r\n'''.codeUnits,
239 { "files": { 'filename': 'myfile', 242 { "files": { 'filename': 'myfile',
240 'contentType': 'application/json', 243 'contentType': 'application/json',
241 'content': 'File content'} }, 244 'content': 'File content'} },
242 "form"); 245 "form");
246
247 test('application/x-www-form-urlencoded',
248 '%E5%B9%B3%3D%E4%BB%AE%E5%90%8D=%26%2324179%3B%26%2320206%3B%26%'
249 '2321517%3B&b=%26%2324179%3B%26%2320206%3B%26%2321517%3B'.codeUnits,
250 { 'b' : '平仮名',
251 '平=仮名' : '平仮名'},
252 "form");
243 } 253 }
244 254
245 void main() { 255 void main() {
246 testHttpClientResponseBody(); 256 testHttpClientResponseBody();
247 testHttpServerRequestBody(); 257 testHttpServerRequestBody();
248 } 258 }
OLDNEW
« no previous file with comments | « sdk/lib/io/http_utils.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698