Skip to content

Add proxy support for WKWebView - #84

Draft
KodamaSakuno wants to merge 1 commit into
AvaloniaUI:mainfrom
KodamaSakuno:webkit-proxy-feature
Draft

KodamaSakuno wants to merge 1 commit into
AvaloniaUI:mainfrom
KodamaSakuno:webkit-proxy-feature

Conversation

@KodamaSakuno

Copy link
Copy Markdown
Contributor

Motivation

WebView2 supports proxy configuration via
AdditionalBrowserArguments (e.g. --proxy-server=host:port). WKWebView should have an equivalent feature since macOS 14 / iOS 17 have supported it.

Summary

Expose proxy configuration via
AppleWKWebViewEnvironmentRequestedEventArgs:

  • ProxyAddress (Uri) — supports http, https and socks5 schemes
  • ProxyCredentials (NetworkCredential) — takes precedence over credentials
    embedded in the proxy URI
  • ProxyExcludedDomains (string[]) — domains bypassing the proxy

Notes

  • I've only tested http proxies.
  • Need discussion for API designs.
  • How to test the behavior using unit tests or samples?

Comment on lines +45 to +59
/// <summary>
/// Gets or sets the proxy address.
/// </summary>
public Uri? ProxyAddress { get; set; }

/// <summary>
/// Gets or sets the credentials used to authenticate with the proxy.
/// If set, this takes precedence over credentials embedded in <see cref="ProxyAddress"/>.
/// </summary>
public NetworkCredential? ProxyCredentials { get; set; }

/// <summary>
/// Gets or sets the list of domains to exclude from the proxy.
/// </summary>
public string[]? ProxyExcludedDomains { get; set; }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it's not typically recommended to reuse types across domains, just because they fit similarly.

But what do you think of using .NET's WebProxy type here?

WebProxy has Address, BypassList and Credentials (proxy.Credentials.GetCredentials("Basic")) that cover these three config properties.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me, WebProxy is suitable here. I need to test its behavior.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants