Skip to content

Obsolete ServicePointManager #71836

@terrajobst

Description

@terrajobst

Edit: Changed the proposal to obsolete the entire class.

Background and motivation

Most of the public API-s exposed by ServicePointManager are unused, having no effect other than being copied to ServicePoint properties. Even properties with actual effect on legacy API-s could be mistakenly used in combo with HttpClient. Team consensus is to obsolete the entire ServicePointManager class if possible.

API proposal

+ [Obsolete(DiagnosticId = Obsoletions.WebRequestDiagId)]
  public class ServicePointManager
  {
-     [Obsolete(DiagnosticId = Obsoletions.WebRequestDiagId)]
      public static ServicePoint FindServicePoint(Uri address);

-     [Obsolete(DiagnosticId = Obsoletions.WebRequestDiagId)]
      public static ServicePoint FindServicePoint(string uriString, IWebProxy? proxy);

-     [Obsolete(DiagnosticId = Obsoletions.WebRequestDiagId)]
      public static ServicePoint FindServicePoint(Uri address, IWebProxy? proxy);
  }

Alternative proposal

Obsolete only unused members.

namespace System.Net;

public partial class ServicePointManager
{
    // Remaining members:
    // public static bool CheckCertificateRevocationList { get; set; }
    // public static SecurityProtocolType SecurityProtocol { get; set; }
    // public static RemoteCertificateValidationCallback? ServerCertificateValidationCallback { get; set; }

    [Obsolete(DiagnosticId = Obsoletions.WebRequestDiagId)]
    public const int DefaultNonPersistentConnectionLimit = 4;
    [Obsolete(DiagnosticId = Obsoletions.WebRequestDiagId)]
    public const int DefaultPersistentConnectionLimit = 2;
    [Obsolete(DiagnosticId = Obsoletions.WebRequestDiagId)]
    public static int DefaultConnectionLimit { get; set; }
    [Obsolete(DiagnosticId = Obsoletions.WebRequestDiagId)]
    public static int DnsRefreshTimeout { get; set; }
    [Obsolete(DiagnosticId = Obsoletions.WebRequestDiagId)]
    public static bool EnableDnsRoundRobin { get; set; }
    [UnsupportedOSPlatform("browser")]
    [Obsolete(DiagnosticId = Obsoletions.WebRequestDiagId)]
    public static EncryptionPolicy EncryptionPolicy { get; }
    [Obsolete(DiagnosticId = Obsoletions.WebRequestDiagId)]
    public static bool Expect100Continue { get; set; }
    [Obsolete(DiagnosticId = Obsoletions.WebRequestDiagId)]
    public static int MaxServicePointIdleTime { get; set; }
    [Obsolete(DiagnosticId = Obsoletions.WebRequestDiagId)]
    public static int MaxServicePoints { get; set; }
    [Obsolete(DiagnosticId = Obsoletions.WebRequestDiagId)]
    public static bool ReusePort { get; set; }
    [Obsolete(DiagnosticId = Obsoletions.WebRequestDiagId)]
    public static bool UseNagleAlgorithm { get; set; }

    // Already obsolete:
    // [Obsolete(DiagnosticId = Obsoletions.WebRequestDiagId)]
    // public static ServicePoint FindServicePoint(string uriString, IWebProxy? proxy);
    // [Obsolete(DiagnosticId = Obsoletions.WebRequestDiagId)]
    // public static ServicePoint FindServicePoint(Uri address);
    // [Obsolete(DiagnosticId = Obsoletions.WebRequestDiagId)]
    // public static ServicePoint FindServicePoint(Uri address, IWebProxy? proxy);
    // [Obsolete(DiagnosticId = Obsoletions.WebRequestDiagId)]
    // public static void SetTcpKeepAlive(bool enabled, int keepAliveTime, int keepAliveInterval);
}

Metadata

Metadata

Assignees

Labels

api-approvedAPI was approved in API review, it can be implementedarea-System.Net.Httpin-prThere is an active PR which will close this issue when it is merged

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions