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

Unified Diff: lib/src/http_date.dart

Issue 1307353003: Add an AuthenticationChallenge class. (Closed) Base URL: git@github.com:dart-lang/http_parser@master
Patch Set: Code review changes Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/authentication_challenge.dart ('k') | lib/src/media_type.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/http_date.dart
diff --git a/lib/src/http_date.dart b/lib/src/http_date.dart
index 7d46d553eda30676d2916fd17f68c06c46beb70b..959053649d845b17ef1c86c1cde7e11e881ec712 100644
--- a/lib/src/http_date.dart
+++ b/lib/src/http_date.dart
@@ -6,6 +6,8 @@ library http_parser.http_date;
import 'package:string_scanner/string_scanner.dart';
+import 'utils.dart';
+
const _WEEKDAYS = const ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
const _MONTHS = const ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
"Sep", "Oct", "Nov", "Dec"];
@@ -48,7 +50,7 @@ String formatHttpDate(DateTime date) {
/// 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3). It will
/// throw a [FormatException] if [date] is invalid.
DateTime parseHttpDate(String date) {
- try {
+ return wrapFormatException("HTTP date", date, () {
var scanner = new StringScanner(date);
if (scanner.scan(_longWeekdayRegExp)) {
@@ -96,9 +98,7 @@ DateTime parseHttpDate(String date) {
scanner.expectDone();
return _makeDateTime(year, month, day, time);
- } on FormatException catch (error) {
- throw new FormatException('Invalid HTTP date "$date": ${error.message}');
- }
+ });
}
/// Parses a short-form month name to a form accepted by [DateTime].
« no previous file with comments | « lib/src/authentication_challenge.dart ('k') | lib/src/media_type.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698