This repository was archived by the owner on Sep 4, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 351
Implement centralized HttpClient service with proxy support #857
Merged
Merged
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
9ec7154
Initial plan
Copilot 86a2f54
Implement HttpClient service infrastructure and update existing services
Copilot 759a84d
Add comprehensive unit tests for HttpClient service
Copilot 1b98c36
Add comprehensive documentation for HttpClient service design
Copilot a508908
Run dotnet format to fix code formatting issues
Copilot 8b793f0
Update CHANGELOG.md with link to PR 857 for HttpClient service implem…
Copilot c8ea353
Fix compilation errors in HttpClient service implementation
Copilot 1955f95
Fix regex parsing error in proxy bypass patterns
Copilot 0f02e9c
Fix whitespace formatting in KustoCommandTests.cs
Copilot 1750a7e
Update .gitignore
jongio c1c172f
Enhance FoundryService constructor to accept optional ITenantService …
jongio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
core/src/AzureMcp.Core/Extensions/HttpClientServiceCollectionExtensions.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using AzureMcp.Core.Services.Http; | ||
| using Microsoft.Extensions.DependencyInjection; | ||
|
|
||
| namespace AzureMcp.Core.Extensions; | ||
|
|
||
| /// <summary> | ||
| /// Extension methods for registering HTTP client services. | ||
| /// </summary> | ||
| public static class HttpClientServiceCollectionExtensions | ||
| { | ||
| /// <summary> | ||
| /// Adds HTTP client services to the service collection with default configuration. | ||
| /// </summary> | ||
| /// <param name="services">The service collection.</param> | ||
| /// <returns>The service collection for chaining.</returns> | ||
| public static IServiceCollection AddHttpClientServices(this IServiceCollection services) | ||
| { | ||
| return services.AddHttpClientServices(_ => { }); | ||
jongio marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| /// <summary> | ||
| /// Adds HTTP client services to the service collection with custom configuration. | ||
| /// </summary> | ||
| /// <param name="services">The service collection.</param> | ||
| /// <param name="configureOptions">Action to configure HttpClient options.</param> | ||
| /// <returns>The service collection for chaining.</returns> | ||
| public static IServiceCollection AddHttpClientServices(this IServiceCollection services, Action<HttpClientOptions> configureOptions) | ||
| { | ||
| ArgumentNullException.ThrowIfNull(services); | ||
jongio marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ArgumentNullException.ThrowIfNull(configureOptions); | ||
|
|
||
| // Configure options with environment variables | ||
| services.Configure<HttpClientOptions>(options => | ||
| { | ||
| // Read proxy configuration from environment variables | ||
| options.AllProxy = Environment.GetEnvironmentVariable("ALL_PROXY"); | ||
| options.HttpProxy = Environment.GetEnvironmentVariable("HTTP_PROXY"); | ||
| options.HttpsProxy = Environment.GetEnvironmentVariable("HTTPS_PROXY"); | ||
| options.NoProxy = Environment.GetEnvironmentVariable("NO_PROXY"); | ||
|
|
||
| // Apply custom configuration | ||
| configureOptions(options); | ||
| }); | ||
|
|
||
| // Register the HTTP client service | ||
| services.AddSingleton<IHttpClientService, HttpClientService>(); | ||
|
|
||
| return services; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| namespace AzureMcp.Core.Services.Http; | ||
|
|
||
| /// <summary> | ||
| /// Configuration options for HttpClient services. | ||
| /// </summary> | ||
| public sealed class HttpClientOptions | ||
| { | ||
| /// <summary> | ||
| /// Gets or sets the HTTP proxy address. Can be set via HTTP_PROXY environment variable. | ||
| /// </summary> | ||
| public string? HttpProxy { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the HTTPS proxy address. Can be set via HTTPS_PROXY environment variable. | ||
| /// </summary> | ||
| public string? HttpsProxy { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the proxy address for all protocols. Can be set via ALL_PROXY environment variable. | ||
| /// </summary> | ||
| public string? AllProxy { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the comma-separated list of hostnames that should bypass the proxy. Can be set via NO_PROXY environment variable. | ||
| /// </summary> | ||
| public string? NoProxy { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the default timeout for HTTP requests. Defaults to 100 seconds. | ||
| /// </summary> | ||
| public TimeSpan DefaultTimeout { get; set; } = TimeSpan.FromSeconds(100); | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the default User-Agent header value. | ||
| /// </summary> | ||
| public string? DefaultUserAgent { get; set; } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.