[io] HttpClient: add a more descriptive message if the HTTP authentication challenge is incorrectly formatted. Bug:https://github.com/dart-lang/sdk/issues/57117 Change-Id: Iceace8ae5c43293f66c2167e2c5ee598e5fecb54 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/402280 Commit-Queue: Brian Quinlan <bquinlan@google.com> Reviewed-by: Lasse Nielsen <lrn@google.com>
diff --git a/sdk/lib/_http/http_impl.dart b/sdk/lib/_http/http_impl.dart index 46cee63..1fe08b6 100644 --- a/sdk/lib/_http/http_impl.dart +++ b/sdk/lib/_http/http_impl.dart
@@ -845,10 +845,18 @@ List<String> challenge = authChallenge()!; assert(challenge.length == 1); - _HeaderValue header = _HeaderValue.parse( - challenge[0], - parameterSeparator: ",", - ); + final _HeaderValue header; + try { + header = _HeaderValue.parse(challenge[0], parameterSeparator: ","); + } on HttpException catch (_, s) { + Error.throwWithStackTrace( + HttpException( + 'The authentication challenge sent by the server is ' + 'not correctly formatted.', + ), + s, + ); + } _AuthenticationScheme scheme = _AuthenticationScheme.fromString( header.value, );