http
http copied to clipboard
Autodetect proxy in windows
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?
I’m not sure if it works on Windows, but have you tried findProxyFromEnvironment?
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
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.
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 :)