Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
HttpAuthority.cs
Go to the documentation of this file.
2
3namespace System.Net.Http;
4
5internal sealed class HttpAuthority : IEquatable<HttpAuthority>
6{
7 public string IdnHost { get; }
8
9 public int Port { get; }
10
11 public HttpAuthority(string host, int port)
12 {
13 UriBuilder uriBuilder = new UriBuilder(Uri.UriSchemeHttp, host, port);
14 Uri uri = uriBuilder.Uri;
15 IdnHost = ((uri.HostNameType == UriHostNameType.IPv6) ? ("[" + uri.IdnHost + "]") : uri.IdnHost);
16 Port = port;
17 }
18
19 public bool Equals([NotNullWhen(true)] HttpAuthority other)
20 {
21 if (other != null && string.Equals(IdnHost, other.IdnHost))
22 {
23 return Port == other.Port;
24 }
25 return false;
26 }
27
28 public override bool Equals([NotNullWhen(true)] object obj)
29 {
30 if (obj is HttpAuthority other)
31 {
32 return Equals(other);
33 }
34 return false;
35 }
36
37 public override int GetHashCode()
38 {
39 return HashCode.Combine(IdnHost, Port);
40 }
41
42 public override string ToString()
43 {
44 if (IdnHost == null)
45 {
46 return "<empty>";
47 }
48 return $"{IdnHost}:{Port}";
49 }
50}
override bool Equals([NotNullWhen(true)] object obj)
HttpAuthority(string host, int port)
bool Equals([NotNullWhen(true)] HttpAuthority other)
string IdnHost
Definition Uri.cs:537
static readonly string UriSchemeHttp
Definition Uri.cs:165