Skip to content

Commit

Permalink
Add basic proxy support for NuGet API V3 (#620)
Browse files Browse the repository at this point in the history
* Windows proxy problem fix

Co-authored-by: JoC0de <[email protected]>
  • Loading branch information
k6a and JoC0de authored Feb 10, 2024
1 parent a8ef661 commit 0d302f6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/NuGetForUnity/Editor/PackageSource/NugetApiClientV3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ internal sealed class NugetApiClientV3 : IDisposable

[NonSerialized]
[NotNull]
private readonly HttpClient httpClient = new HttpClient(
new HttpClientHandler { AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate });
private readonly HttpClient httpClient;

[NonSerialized]
[CanBeNull]
Expand Down Expand Up @@ -83,6 +82,15 @@ public NugetApiClientV3([NotNull] string url)

apiIndexJsonUrl = new Uri(url);

var handler = new HttpClientHandler { AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate };
if (Application.platform == RuntimePlatform.WindowsEditor)
{
// On Windows, Mono HttpClient does not automatically pick up proxy settings.
handler.Proxy = WebRequest.GetSystemWebProxy();
}

httpClient = new HttpClient(handler);

InitializeFromSessionState();
}

Expand Down

0 comments on commit 0d302f6

Please sign in to comment.