diff --git a/src/Mono.Android/Xamarin.Android.Net/AndroidMessageHandler.cs b/src/Mono.Android/Xamarin.Android.Net/AndroidMessageHandler.cs index 403f5a0ab2d..706f22fc63c 100644 --- a/src/Mono.Android/Xamarin.Android.Net/AndroidMessageHandler.cs +++ b/src/Mono.Android/Xamarin.Android.Net/AndroidMessageHandler.cs @@ -149,10 +149,34 @@ public void Reset () bool decompress_here => _acceptEncoding is not null && _acceptEncoding != IDENTITY_ENCODING; string? _acceptEncoding; + /// + /// Gets a value indicating whether the handler supports automatic response content decompression. + /// Always returns for . + /// public bool SupportsAutomaticDecompression => true; + + /// + /// Gets a value indicating whether the handler supports proxy settings. + /// Always returns for . + /// public bool SupportsProxy => true; + + /// + /// Gets a value indicating whether the handler supports configuration settings for the + /// and properties. + /// Always returns for . + /// public bool SupportsRedirectConfiguration => true; + /// + /// Gets or sets the type of decompression method used by the handler for automatic + /// decompression of the HTTP content response. + /// + /// + /// Supported methods are , + /// , and . + /// Set to to disable automatic decompression. + /// public DecompressionMethods AutomaticDecompression { get => _decompressionMethods; @@ -181,6 +205,10 @@ public DecompressionMethods AutomaticDecompression } } + /// + /// Gets or sets the cookie container used to store server cookies. + /// + /// The value specified is . public CookieContainer CookieContainer { get => _cookieContainer ?? (_cookieContainer = new CookieContainer ()); @@ -196,21 +224,55 @@ public CookieContainer CookieContainer // NOTE: defaults here are based on: // https://github.com/dotnet/runtime/blob/f3b77e64b87895aa7e697f321eb6d4151a4333df/src/libraries/Common/src/System/Net/Http/HttpHandlerDefaults.cs + /// + /// Gets or sets a value that indicates whether the handler uses the + /// property to store server cookies and uses these cookies when sending requests. The default value + /// is . + /// public bool UseCookies { get; set; } = true; + /// + /// Gets or sets a value that indicates whether the handler sends an Authorization header with the + /// request. The default value is . + /// public bool PreAuthenticate { get; set; } = false; + /// + /// Gets or sets a value that indicates whether the handler uses a proxy for requests. The default + /// value is . + /// public bool UseProxy { get; set; } = true; + /// + /// Gets or sets the proxy information used by the handler. + /// public IWebProxy? Proxy { get; set; } + /// + /// Gets or sets authentication information used by this handler. + /// public ICredentials? Credentials { get; set; } + /// + /// Gets or sets a value that indicates whether the handler should follow redirection responses. + /// The default value is . + /// public bool AllowAutoRedirect { get; set; } = true; + /// + /// Gets or sets a value that indicates how client certificates are provided. The default value is + /// . + /// public ClientCertificateOption ClientCertificateOptions { get; set; } = ClientCertificateOption.Manual; private X509CertificateCollection? _clientCertificates; + + /// + /// Gets or sets the collection of client certificates used by the handler to authenticate the client. + /// + /// + /// is not set to . + /// public X509CertificateCollection? ClientCertificates { get @@ -225,16 +287,35 @@ public X509CertificateCollection? ClientCertificates set => _clientCertificates = value; } + /// + /// Gets or sets the credentials to use when authenticating with the proxy. + /// public ICredentials? DefaultProxyCredentials { get; set; } + /// + /// Gets or sets the maximum number of concurrent connections allowed per server. The default value + /// is . + /// public int MaxConnectionsPerServer { get; set; } = int.MaxValue; + /// + /// Gets or sets the maximum length, in kilobytes (1024 bytes), of the response headers. The default + /// value is 64 KB. + /// public int MaxResponseHeadersLength { get; set; } = 64; // Units in K (1024) bytes. + /// + /// Gets or sets a value that indicates whether the certificate revocation list is checked during + /// validation. The default value is . + /// public bool CheckCertificateRevocationList { get; set; } = false; ServerCertificateCustomValidator? _serverCertificateCustomValidator = null; + /// + /// Gets or sets a callback to validate the server certificate. When set, the callback is invoked + /// during the TLS handshake to perform custom certificate validation. + /// public Func? ServerCertificateCustomValidationCallback { get => _serverCertificateCustomValidator?.Callback; @@ -249,15 +330,34 @@ public X509CertificateCollection? ClientCertificates } } + /// + /// Gets or sets the TLS/SSL protocols used by the handler. The default value is + /// | on Android API 29+, + /// or on earlier versions. + /// + /// + /// See the + /// Android SSLSocket documentation for details on supported protocols by API level. + /// // See: https://developer.android.com/reference/javax/net/ssl/SSLSocket#protocols public SslProtocols SslProtocols { get; set; } = (int)Build.VERSION.SdkInt >= 29 ? SslProtocols.Tls13 | SslProtocols.Tls12 : SslProtocols.Tls12; + /// + /// Gets or sets a custom property collection for the handler. This can be used to pass + /// additional metadata or configuration to the underlying transport. + /// public IDictionary? Properties { get; set; } int maxAutomaticRedirections = 50; + /// + /// Gets or sets the maximum number of allowed HTTP redirects. The default value is 50. + /// + /// + /// The specified value is less than or equal to 0. + /// public int MaxAutomaticRedirections { get => maxAutomaticRedirections;