Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set proxy for BrowserHttpClientAdapter #2270

Closed
demirdev opened this issue Jul 17, 2024 · 1 comment
Closed

set proxy for BrowserHttpClientAdapter #2270

demirdev opened this issue Jul 17, 2024 · 1 comment

Comments

@demirdev
Copy link

demirdev commented Jul 17, 2024

Request Statement

I wrote useProxy method in this extension for set proxy to the http client adapter for dio. It works on android and iOS.
But in the web browser, how can I do this with BrowserHttpClientAdapter ?

/// Methods for managing proxies on [Dio]
extension ProxyX on Dio {
  /// Use a proxy to connect to the internet.
  ///
  /// If [proxyUrl] is a non-empty, non-null String, connect to the proxy server.
  ///
  /// If [proxyUrl] is empty or `null`, does nothing.
  void useProxy(String? proxyUrl) {
    if (proxyUrl != null && proxyUrl.isNotEmpty) {
      if (httpClientAdapter is IOHttpClientAdapter) {
        (httpClientAdapter as IOHttpClientAdapter).onHttpClientCreate =
            (client) => client
              ..findProxy = (url) {
                return 'PROXY $proxyUrl';
              };
      }
    } else {
      httpClientAdapter = getDioHTTPClientAdapter();
    }
  }
}

Solution Brainstorm

No response

@demirdev demirdev added the s: feature This issue indicates a feature request label Jul 17, 2024
@AlexV525
Copy link
Member

You can't, or you can ask Dart to add the support.

@AlexV525 AlexV525 closed this as not planned Won't fix, can't repro, duplicate, stale Jul 18, 2024
@AlexV525 AlexV525 added i: out of support and removed s: feature This issue indicates a feature request labels Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants