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

Side by Side Diff: runtime/bin/http_utils.dart

Issue 10887023: Use new try-catch syntax in runtime/, tools/, and utils/. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 | « runtime/bin/http_parser.dart ('k') | runtime/bin/websocket_impl.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 class _HttpUtils { 5 class _HttpUtils {
6 static String decodeUrlEncodedString(String urlEncoded) { 6 static String decodeUrlEncodedString(String urlEncoded) {
7 // First check the string for any encoding. 7 // First check the string for any encoding.
8 int index = 0; 8 int index = 0;
9 bool encoded = false; 9 bool encoded = false;
10 while (!encoded && index < urlEncoded.length) { 10 while (!encoded && index < urlEncoded.length) {
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 if (separator.length > 0) { 205 if (separator.length > 0) {
206 pos = date.indexOf(separator, index); 206 pos = date.indexOf(separator, index);
207 } else { 207 } else {
208 pos = date.length; 208 pos = date.length;
209 } 209 }
210 String tmp = date.substring(index, pos); 210 String tmp = date.substring(index, pos);
211 index = pos + separator.length; 211 index = pos + separator.length;
212 try { 212 try {
213 int value = parseInt(tmp); 213 int value = parseInt(tmp);
214 return value; 214 return value;
215 } catch (FormatException e) { 215 } on FormatException catch (e) {
216 throw new HttpException("Invalid HTTP date $date"); 216 throw new HttpException("Invalid HTTP date $date");
217 } 217 }
218 } 218 }
219 219
220 void expectEnd() { 220 void expectEnd() {
221 if (index != date.length) { 221 if (index != date.length) {
222 throw new HttpException("Invalid HTTP date $date"); 222 throw new HttpException("Invalid HTTP date $date");
223 } 223 }
224 } 224 }
225 225
(...skipping 20 matching lines...) Expand all
246 hours = expectNum(":"); 246 hours = expectNum(":");
247 minutes = expectNum(":"); 247 minutes = expectNum(":");
248 seconds = expectNum(" "); 248 seconds = expectNum(" ");
249 expect("GMT"); 249 expect("GMT");
250 } 250 }
251 expectEnd(); 251 expectEnd();
252 return new Date( 252 return new Date(
253 year, month + 1, day, hours, minutes, seconds, 0, isUtc: true); 253 year, month + 1, day, hours, minutes, seconds, 0, isUtc: true);
254 } 254 }
255 } 255 }
OLDNEW
« no previous file with comments | « runtime/bin/http_parser.dart ('k') | runtime/bin/websocket_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698