http icon indicating copy to clipboard operation
http copied to clipboard

Autodetect proxy in windows

Open Mapashito1 opened this issue 2 years ago • 4 comments

Hi,

I use http package to connect through the proxy in windows and it works.

httpClient.findProxy = (uri) { return "PROXY ip:port"; }; IOClient client = IOClient(httpClient);

The problem is I have to manually configure it on each computer.

How can I autodetect if windows has a proxy? image

Mapashito1 avatar May 31 '23 13:05 Mapashito1

I’m not sure if it works on Windows, but have you tried findProxyFromEnvironment?

SamJakob avatar Jul 16 '23 20:07 SamJakob

I’m not sure if it works on Windows, but have you tried findProxyFromEnvironment?

Yep, I have tried but it is not work in windows :( I imagine it is a feature only for android/ios

Mapashito1 avatar Jul 17 '23 14:07 Mapashito1

Hmm, and/or Unix-like (i.e., macOS/Linux).

Another option could be to read it manually and check - e.g., using something like the platform_proxy package (or implementing it in platform channels yourself if you feel it's worth the effort).

I'm not a maintainer or author of this package by the way, but this seems like it would be out of scope of the http package anyhow. Seeing as the proxy configuration happens on HttpClient from dart:io, it might be worth filing an issue over at dart-lang/sdk about getting that to work on Windows.

SamJakob avatar Jul 17 '23 16:07 SamJakob

This is not just a 'Windows' issue - all Flutter apps don't use the system proxy by default as reported here: https://github.com/flutter/flutter/issues/26359 - as Flutter becomes adopted by more and more enterprise clients, and those often rely on the system proxies it would be great to address this issue (either through adding more documentation and making people aware that http does not behave like a client in the 'competing' frameworks or by adding the functionality. Imho both options are valid but adding the functionality would probably be my favourite :)

dkbast avatar Feb 16 '24 10:02 dkbast