diff --git a/sdk/lib/_http/http_impl.dart b/sdk/lib/_http/http_impl.dart index 46cee6367a4..1fe08b6d4f0 100644 --- a/sdk/lib/_http/http_impl.dart +++ b/sdk/lib/_http/http_impl.dart @@ -845,10 +845,18 @@ class _HttpClientResponse extends _HttpInboundMessageListInt List 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, );