From d2d2bf8e4fd98071750fbbcaeae2ed6bb2f4fd8f Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Thu, 2 Jan 2025 13:26:38 -0800 Subject: [PATCH] [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 Reviewed-by: Lasse Nielsen --- sdk/lib/_http/http_impl.dart | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) 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, );