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

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

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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_parser.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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 int expectNum(String separator) { 200 int expectNum(String separator) {
201 int pos; 201 int pos;
202 if (separator.length > 0) { 202 if (separator.length > 0) {
203 pos = date.indexOf(separator, index); 203 pos = date.indexOf(separator, index);
204 } else { 204 } else {
205 pos = date.length; 205 pos = date.length;
206 } 206 }
207 String tmp = date.substring(index, pos); 207 String tmp = date.substring(index, pos);
208 index = pos + separator.length; 208 index = pos + separator.length;
209 try { 209 try {
210 int value = parseInt(tmp); 210 int value = int.parse(tmp);
211 return value; 211 return value;
212 } on FormatException catch (e) { 212 } on FormatException catch (e) {
213 throw new HttpException("Invalid HTTP date $date"); 213 throw new HttpException("Invalid HTTP date $date");
214 } 214 }
215 } 215 }
216 216
217 void expectEnd() { 217 void expectEnd() {
218 if (index != date.length) { 218 if (index != date.length) {
219 throw new HttpException("Invalid HTTP date $date"); 219 throw new HttpException("Invalid HTTP date $date");
220 } 220 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 } 293 }
294 294
295 int getMonth(String month) { 295 int getMonth(String month) {
296 if (month.length < 3) return -1; 296 if (month.length < 3) return -1;
297 return monthsLowerCase.indexOf(month.substring(0, 3)); 297 return monthsLowerCase.indexOf(month.substring(0, 3));
298 } 298 }
299 299
300 int toInt(String s) { 300 int toInt(String s) {
301 int index = 0; 301 int index = 0;
302 for (; index < s.length && isDigit(s[index]); index++); 302 for (; index < s.length && isDigit(s[index]); index++);
303 return parseInt(s.substring(0, index)); 303 return int.parse(s.substring(0, index));
304 } 304 }
305 305
306 var tokens = []; 306 var tokens = [];
307 while (!isEnd()) { 307 while (!isEnd()) {
308 while (!isEnd() && isDelimiter(date[position])) position++; 308 while (!isEnd() && isDelimiter(date[position])) position++;
309 int start = position; 309 int start = position;
310 while (!isEnd() && isNonDelimiter(date[position])) position++; 310 while (!isEnd() && isNonDelimiter(date[position])) position++;
311 tokens.add(date.substring(start, position).toLowerCase()); 311 tokens.add(date.substring(start, position).toLowerCase());
312 while (!isEnd() && isDelimiter(date[position])) position++; 312 while (!isEnd() && isDelimiter(date[position])) position++;
313 } 313 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 Date.utc(year, month, dayOfMonth, hour, minute, second, 0); 359 return new Date.utc(year, month, dayOfMonth, hour, minute, second, 0);
360 } 360 }
361 } 361 }
OLDNEW
« no previous file with comments | « sdk/lib/io/http_parser.dart ('k') | sdk/lib/io/io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698