Terraria v1.4.4.9
Terraria source code documentation
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros
HttpEnvironmentProxyCredentials.cs
Go to the documentation of this file.
1namespace System.Net.Http;
2
4{
5 private readonly NetworkCredential _httpCred;
6
7 private readonly NetworkCredential _httpsCred;
8
9 private readonly Uri _httpProxy;
10
11 private readonly Uri _httpsProxy;
12
13 public HttpEnvironmentProxyCredentials(Uri httpProxy, NetworkCredential httpCred, Uri httpsProxy, NetworkCredential httpsCred)
14 {
15 _httpCred = httpCred;
16 _httpsCred = httpsCred;
17 _httpProxy = httpProxy;
18 _httpsProxy = httpsProxy;
19 }
20
21 public NetworkCredential GetCredential(Uri uri, string authType)
22 {
23 if (uri == null)
24 {
25 return null;
26 }
27 if (!uri.Equals(_httpProxy))
28 {
29 if (!uri.Equals(_httpsProxy))
30 {
31 return null;
32 }
33 return _httpsCred;
34 }
35 return _httpCred;
36 }
37
38 public static HttpEnvironmentProxyCredentials TryCreate(Uri httpProxy, Uri httpsProxy)
39 {
40 NetworkCredential networkCredential = null;
41 NetworkCredential networkCredential2 = null;
42 if (httpProxy != null)
43 {
44 networkCredential = GetCredentialsFromString(httpProxy.UserInfo);
45 }
46 if (httpsProxy != null)
47 {
48 networkCredential2 = GetCredentialsFromString(httpsProxy.UserInfo);
49 }
50 if (networkCredential == null && networkCredential2 == null)
51 {
52 return null;
53 }
54 return new HttpEnvironmentProxyCredentials(httpProxy, networkCredential, httpsProxy, networkCredential2);
55 }
56
58 {
59 if (string.IsNullOrWhiteSpace(value))
60 {
61 return null;
62 }
64 string password = "";
65 string domain = null;
66 int num = value.IndexOf(':');
67 if (num != -1)
68 {
69 password = value.Substring(num + 1);
70 value = value.Substring(0, num);
71 }
72 num = value.IndexOf('\\');
73 if (num != -1)
74 {
75 domain = value.Substring(0, num);
76 value = value.Substring(num + 1);
77 }
78 return new NetworkCredential(value, password, domain);
79 }
80}
static NetworkCredential GetCredentialsFromString(string value)
HttpEnvironmentProxyCredentials(Uri httpProxy, NetworkCredential httpCred, Uri httpsProxy, NetworkCredential httpsCred)
NetworkCredential GetCredential(Uri uri, string authType)
static HttpEnvironmentProxyCredentials TryCreate(Uri httpProxy, Uri httpsProxy)
string UserInfo
Definition Uri.cs:577
override bool Equals([NotNullWhen(true)] object? comparand)
Definition Uri.cs:1166
static string UnescapeDataString(string stringToUnescape)
Definition Uri.cs:4058