Skip to content

Commit 8903c42

Browse files
committed
Update based on feedback
1 parent 627e1e4 commit 8903c42

2 files changed

Lines changed: 4 additions & 7 deletions

File tree

src/ModelContextProtocol/Authentication/AuthorizationDelegatingHandler.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,9 @@ private async Task<HttpResponseMessage> HandleUnauthorizedResponseAsync(
7171
}
7272
else
7373
{
74-
// Try to find any matching scheme between server and provider using a HashSet for O(N) time complexity
75-
// Convert the supported schemes to a HashSet for O(1) lookups
76-
var supportedSchemesSet = new HashSet<string>(supportedSchemes, StringComparer.OrdinalIgnoreCase);
77-
7874
// Find the first server scheme that's in our supported set
79-
bestSchemeMatch = serverSchemes.FirstOrDefault(scheme => supportedSchemesSet.Contains(scheme));
80-
75+
bestSchemeMatch = serverSchemes.Intersect(supportedSchemes, StringComparer.OrdinalIgnoreCase).FirstOrDefault();
76+
8177
// If no match was found, either throw an exception or use default
8278
if (bestSchemeMatch is null)
8379
{

src/ModelContextProtocol/Authentication/AuthorizationHelpers.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ public static class AuthorizationHelpers
2222
using var httpClient = new HttpClient();
2323
try
2424
{
25-
var response = await httpClient.GetAsync(metadataUrl, cancellationToken).ConfigureAwait(false);
25+
var request = new HttpRequestMessage(HttpMethod.Get, metadataUrl);
26+
var response = await httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
2627
response.EnsureSuccessStatusCode();
2728

2829
var content = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);

0 commit comments

Comments
 (0)