GlitchEnzo / NuGetForUnity

A NuGet Package Manager for Unity
MIT License
3.13k stars 310 forks source link

Add basic proxy support for NuGet API V3 #620

Closed k6a closed 7 months ago

k6a commented 8 months ago

The default proxy setup was missing in HttpClient/HttpClientHander initializaion. By adding WebRequest.DefaultWebProxy client will look for HTTP_PROXY, NO_PROXY environment variables if it exists.

Tested on Unity 2018.3.0, 2022.3.18, and Squid 5.7.

JoC0de commented 8 months ago

Are you sure it didn't work as it was before? As far as I understand the documentation https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpclienthandler.proxy?view=net-8.0 it is the default behavior.

k6a commented 8 months ago

@JoC0de Thanks for your response!

I just got started using this great plugin in about a week ago. Still figuring out how to use it in corporate proxy (harsh) environment.

Further tested and found that the symptom only occurs on Windows + (corporate) proxy enabled environment.

On MacOS, it works just fine (without the fix).

The documentation you mentioned explains the behaviour of HttpClientHandler on .NET runtime.

Since the Unity Editor runs on Mono runtime, internal structures and behaviours are slightly different than that of .NET runtime.

Reference source for both runtimes:

.NET:

Mono:

And yes, .NET does setup system proxy on initialization whereas Mono doesn't.