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

Side by Side Diff: sdk/lib/io/http_utils.dart

Issue 14796015: Add new HttpMultipartFormData, used for parsing a MimeMultipart and extracting either text or binar… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update doc comments. 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_multipart_form_data_impl.dart ('k') | sdk/lib/io/io.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 part of dart.io; 5 part of dart.io;
6 6
7 class _HttpUtils { 7 class _HttpUtils {
8 static String decodeUrlEncodedString(String urlEncoded) { 8 static String decodeUrlEncodedString(String urlEncoded) {
9 // First check the string for any encoding. 9 // First check the string for any encoding.
10 int index = 0; 10 int index = 0;
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 if (timeList.length != 3) error(); 351 if (timeList.length != 3) error();
352 int hour = toInt(timeList[0]); 352 int hour = toInt(timeList[0]);
353 int minute = toInt(timeList[1]); 353 int minute = toInt(timeList[1]);
354 int second = toInt(timeList[2]); 354 int second = toInt(timeList[2]);
355 if (hour > 23) error(); 355 if (hour > 23) error();
356 if (minute > 59) error(); 356 if (minute > 59) error();
357 if (second > 59) error(); 357 if (second > 59) error();
358 358
359 return new DateTime.utc(year, month, dayOfMonth, hour, minute, second, 0); 359 return new DateTime.utc(year, month, dayOfMonth, hour, minute, second, 0);
360 } 360 }
361
362 // Parse a string with HTTP entities. Returns null if the string ends in the
363 // middle of a http entity.
364 static String parseHttpEntityString(String input) {
365 int amp = input.lastIndexOf('&');
366 if (amp < 0) return input;
367 int end = input.lastIndexOf(';');
368 if (end < amp) return null;
369
370 var buffer = new StringBuffer();
371 int offset = 0;
372
373 parse(amp, end) {
374 switch (input[amp + 1]) {
375 case '#':
376 if (input[amp + 2] == 'x') {
377 buffer.writeCharCode(
378 int.parse(input.substring(amp + 3, end), radix: 16));
379 } else {
380 buffer.writeCharCode(int.parse(input.substring(amp + 2, end)));
381 }
382 break;
383
384 default:
385 throw new HttpException('Unhandled HTTP entity token');
386 }
387 }
388
389 while ((amp = input.indexOf('&', offset)) >= 0) {
390 buffer.write(input.substring(offset, amp));
391 int end = input.indexOf(';', amp);
392 parse(amp, end);
393 offset = end + 1;
394 }
395 buffer.write(input.substring(offset));
396 return buffer.toString();
397 }
361 } 398 }
OLDNEW
« no previous file with comments | « sdk/lib/io/http_multipart_form_data_impl.dart ('k') | sdk/lib/io/io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698