Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
HttpWebRequest.cs
Go to the documentation of this file.
3using System.IO;
13
14namespace System.Net;
15
17{
18 [Flags]
19 private enum Booleans : uint
20 {
24 ProxySet = 0x10u,
26 IsVersionHttp10 = 0x80u,
27 SendChunked = 0x100u,
29 IsTunnelRequest = 0x400u,
30 IsWebSocketRequest = 0x800u,
31 Default = 7u
32 }
33
34 private sealed class HttpClientParameters
35 {
36 public readonly bool Async;
37
39
40 public readonly bool AllowAutoRedirect;
41
42 public readonly int MaximumAutomaticRedirections;
43
44 public readonly int MaximumResponseHeadersLength;
45
46 public readonly bool PreAuthenticate;
47
48 public readonly int ReadWriteTimeout;
49
50 public readonly TimeSpan Timeout;
51
53
54 public readonly bool CheckCertificateRevocationList;
55
56 public readonly ICredentials Credentials;
57
58 public readonly IWebProxy Proxy;
59
60 public readonly RemoteCertificateValidationCallback ServerCertificateValidationCallback;
61
63
65
84
86 {
87 if (Async == requestParameters.Async && AutomaticDecompression == requestParameters.AutomaticDecompression && AllowAutoRedirect == requestParameters.AllowAutoRedirect && MaximumAutomaticRedirections == requestParameters.MaximumAutomaticRedirections && MaximumResponseHeadersLength == requestParameters.MaximumResponseHeadersLength && PreAuthenticate == requestParameters.PreAuthenticate && ReadWriteTimeout == requestParameters.ReadWriteTimeout && Timeout == requestParameters.Timeout && SslProtocols == requestParameters.SslProtocols && CheckCertificateRevocationList == requestParameters.CheckCertificateRevocationList && Credentials == requestParameters.Credentials && Proxy == requestParameters.Proxy && (object)ServerCertificateValidationCallback == requestParameters.ServerCertificateValidationCallback && ClientCertificates == requestParameters.ClientCertificates)
88 {
90 }
91 return false;
92 }
93
95 {
97 {
98 return CookieContainer == null;
99 }
100 return false;
101 }
102 }
103
105
106 private readonly Uri _requestUri;
107
108 private string _originVerb = HttpMethod.Get.Method;
109
110 private int _continueTimeout = 350;
111
113
115
117
119
121
122 private static int _defaultMaxResponseHeadersLength = 64;
123
125
127
129
131
133
135
137
138 private int _timeout = 100000;
139
140 private int _readWriteTimeout = 300000;
141
142 private HttpContinueDelegate _continueDelegate;
143
144 private bool _hostHasPort;
145
146 private Uri _hostUri;
147
149
151
153
154 private AsyncCallback _requestStreamCallback;
155
156 private AsyncCallback _responseCallback;
157
158 private int _abortCalled;
159
161
163
164 private Booleans _booleans = Booleans.Default;
165
166 private bool _pipelined = true;
167
168 private bool _preAuthenticate;
169
171
172 private static readonly object s_syncRoot = new object();
173
174 private static volatile HttpClient s_cachedHttpClient;
175
177
178 private static readonly string[] s_wellKnownContentHeaders = new string[10] { "Content-Disposition", "Content-Encoding", "Content-Language", "Content-Length", "Content-Location", "Content-MD5", "Content-Range", "Content-Type", "Expires", "Last-Modified" };
179
180 public string? Accept
181 {
182 get
183 {
184 return _webHeaderCollection["Accept"];
185 }
186 set
187 {
188 SetSpecialHeaders("Accept", value);
189 }
190 }
191
192 public virtual bool AllowReadStreamBuffering
193 {
194 get
195 {
197 }
198 set
199 {
201 }
202 }
203
205 {
206 get
207 {
209 }
210 set
211 {
213 {
215 }
216 if (value < 0 && value != -1)
217 {
219 }
221 }
222 }
223
225 {
226 get
227 {
229 }
230 set
231 {
232 if (value <= 0)
233 {
234 throw new ArgumentException(System.SR.net_toosmall, "value");
235 }
237 }
238 }
239
240 public override string? ContentType
241 {
242 get
243 {
244 return _webHeaderCollection["Content-Type"];
245 }
246 set
247 {
248 SetSpecialHeaders("Content-Type", value);
249 }
250 }
251
253 {
254 get
255 {
256 return _continueTimeout;
257 }
258 set
259 {
261 {
263 }
264 if (value < 0 && value != -1)
265 {
267 }
269 }
270 }
271
272 public override int Timeout
273 {
274 get
275 {
276 return _timeout;
277 }
278 set
279 {
280 if (value < 0 && value != -1)
281 {
283 }
284 _timeout = value;
285 }
286 }
287
288 public override long ContentLength
289 {
290 get
291 {
292 long.TryParse(_webHeaderCollection["Content-Length"], out var result);
293 return result;
294 }
295 set
296 {
298 {
300 }
301 if (value < 0)
302 {
304 }
305 SetSpecialHeaders("Content-Length", value.ToString());
306 }
307 }
308
310
311 public string? UserAgent
312 {
313 get
314 {
315 return _webHeaderCollection["User-Agent"];
316 }
317 set
318 {
319 SetSpecialHeaders("User-Agent", value);
320 }
321 }
322
323 public string Host
324 {
325 get
326 {
327 Uri uri = _hostUri ?? Address;
328 if ((!(_hostUri == null) && _hostHasPort) || !Address.IsDefaultPort)
329 {
330 return uri.Host + ":" + uri.Port;
331 }
332 return uri.Host;
333 }
334 set
335 {
337 {
339 }
340 if (value == null)
341 {
342 throw new ArgumentNullException("value");
343 }
344 if (value.Contains('/') || !TryGetHostUri(value, out var hostUri))
345 {
346 throw new ArgumentException(System.SR.net_invalid_host, "value");
347 }
350 {
351 _hostHasPort = true;
352 return;
353 }
354 if (!value.Contains(':'))
355 {
356 _hostHasPort = false;
357 return;
358 }
359 int num = value.IndexOf(']');
360 _hostHasPort = num == -1 || value.LastIndexOf(':') > num;
361 }
362 }
363
364 public bool Pipelined
365 {
366 get
367 {
368 return _pipelined;
369 }
370 set
371 {
373 }
374 }
375
376 public string? Referer
377 {
378 get
379 {
380 return _webHeaderCollection["Referer"];
381 }
382 set
383 {
384 SetSpecialHeaders("Referer", value);
385 }
386 }
387
388 public string? MediaType { get; set; }
389
390 public string? TransferEncoding
391 {
392 get
393 {
394 return _webHeaderCollection["Transfer-Encoding"];
395 }
396 set
397 {
398 if (string.IsNullOrWhiteSpace(value))
399 {
400 _webHeaderCollection.Remove("Transfer-Encoding");
401 return;
402 }
403 if (value.IndexOf("chunked", StringComparison.OrdinalIgnoreCase) != -1)
404 {
405 throw new ArgumentException(System.SR.net_nochunked, "value");
406 }
407 if (!SendChunked)
408 {
410 }
412 _webHeaderCollection["Transfer-Encoding"] = value2;
413 }
414 }
415
416 public bool KeepAlive { get; set; } = true;
417
418
420 {
421 get
422 {
423 return (_booleans & Booleans.UnsafeAuthenticatedConnectionSharing) != 0;
424 }
425 set
426 {
427 if (value)
428 {
429 _booleans |= Booleans.UnsafeAuthenticatedConnectionSharing;
430 }
431 else
432 {
433 _booleans &= ~Booleans.UnsafeAuthenticatedConnectionSharing;
434 }
435 }
436 }
437
439 {
440 get
441 {
443 }
444 set
445 {
447 {
449 }
451 }
452 }
453
454 public virtual bool AllowWriteStreamBuffering
455 {
456 get
457 {
458 return (_booleans & Booleans.AllowWriteStreamBuffering) != 0;
459 }
460 set
461 {
462 if (value)
463 {
464 _booleans |= Booleans.AllowWriteStreamBuffering;
465 }
466 else
467 {
468 _booleans &= ~Booleans.AllowWriteStreamBuffering;
469 }
470 }
471 }
472
473 public virtual bool AllowAutoRedirect
474 {
475 get
476 {
477 return (_booleans & Booleans.AllowAutoRedirect) != 0;
478 }
479 set
480 {
481 if (value)
482 {
483 _booleans |= Booleans.AllowAutoRedirect;
484 }
485 else
486 {
487 _booleans &= ~Booleans.AllowAutoRedirect;
488 }
489 }
490 }
491
492 public override string? ConnectionGroupName { get; set; }
493
494 public override bool PreAuthenticate
495 {
496 get
497 {
498 return _preAuthenticate;
499 }
500 set
501 {
503 }
504 }
505
506 public string? Connection
507 {
508 get
509 {
510 return _webHeaderCollection["Connection"];
511 }
512 set
513 {
514 if (string.IsNullOrWhiteSpace(value))
515 {
516 _webHeaderCollection.Remove("Connection");
517 return;
518 }
519 bool flag = value.IndexOf("keep-alive", StringComparison.OrdinalIgnoreCase) != -1;
520 bool flag2 = value.IndexOf("close", StringComparison.OrdinalIgnoreCase) != -1;
521 if (flag || flag2)
522 {
523 throw new ArgumentException(System.SR.net_connarg, "value");
524 }
526 _webHeaderCollection["Connection"] = value2;
527 }
528 }
529
530 public string? Expect
531 {
532 get
533 {
534 return _webHeaderCollection["Expect"];
535 }
536 set
537 {
538 if (string.IsNullOrWhiteSpace(value))
539 {
541 return;
542 }
543 if (value.IndexOf("100-continue", StringComparison.OrdinalIgnoreCase) != -1)
544 {
545 throw new ArgumentException(System.SR.net_no100, "value");
546 }
548 _webHeaderCollection["Expect"] = value2;
549 }
550 }
551
553 {
554 get
555 {
557 }
558 set
559 {
561 }
562 }
563
564 public static int DefaultMaximumErrorResponseLength { get; set; }
565
566 public new static RequestCachePolicy? DefaultCachePolicy { get; set; } = new RequestCachePolicy(RequestCacheLevel.BypassCache);
567
568
570 {
571 get
572 {
573 return GetDateHeaderHelper("If-Modified-Since");
574 }
575 set
576 {
577 SetDateHeaderHelper("If-Modified-Since", value);
578 }
579 }
580
582 {
583 get
584 {
585 return GetDateHeaderHelper("Date");
586 }
587 set
588 {
589 SetDateHeaderHelper("Date", value);
590 }
591 }
592
593 public bool SendChunked
594 {
595 get
596 {
597 return (_booleans & Booleans.SendChunked) != 0;
598 }
599 set
600 {
602 {
604 }
605 if (value)
606 {
607 _booleans |= Booleans.SendChunked;
608 }
609 else
610 {
611 _booleans &= ~Booleans.SendChunked;
612 }
613 }
614 }
615
616 public HttpContinueDelegate? ContinueDelegate
617 {
618 get
619 {
620 return _continueDelegate;
621 }
622 set
623 {
625 }
626 }
627
629
630 public RemoteCertificateValidationCallback? ServerCertificateValidationCallback { get; set; }
631
633 {
634 get
635 {
637 }
638 set
639 {
640 _clientCertificates = value ?? throw new ArgumentNullException("value");
641 }
642 }
643
645 {
646 get
647 {
648 if (!IsVersionHttp10)
649 {
650 return HttpVersion.Version11;
651 }
652 return HttpVersion.Version10;
653 }
654 set
655 {
656 if (value.Equals(HttpVersion.Version11))
657 {
658 IsVersionHttp10 = false;
659 return;
660 }
661 if (value.Equals(HttpVersion.Version10))
662 {
663 IsVersionHttp10 = true;
664 return;
665 }
666 throw new ArgumentException(System.SR.net_wrongversion, "value");
667 }
668 }
669
671 {
672 get
673 {
674 return _readWriteTimeout;
675 }
676 set
677 {
679 {
681 }
682 if (value <= 0 && value != -1)
683 {
685 }
687 }
688 }
689
691 {
692 get
693 {
694 return _cookieContainer;
695 }
696 set
697 {
699 }
700 }
701
702 public override ICredentials? Credentials
703 {
704 get
705 {
706 return _credentials;
707 }
708 set
709 {
711 }
712 }
713
714 public virtual bool HaveResponse
715 {
716 get
717 {
718 if (_sendRequestTask != null)
719 {
721 }
722 return false;
723 }
724 }
725
726 public override WebHeaderCollection Headers
727 {
728 get
729 {
731 }
732 set
733 {
735 {
737 }
739 string[] allKeys = value.AllKeys;
740 foreach (string name in allKeys)
741 {
742 webHeaderCollection[name] = value[name];
743 }
745 }
746 }
747
748 public override string Method
749 {
750 get
751 {
752 return _originVerb;
753 }
754 set
755 {
756 if (string.IsNullOrEmpty(value))
757 {
758 throw new ArgumentException(System.SR.net_badmethod, "value");
759 }
761 {
762 throw new ArgumentException(System.SR.net_badmethod, "value");
763 }
765 }
766 }
767
768 public override Uri RequestUri => _requestUri;
769
770 public virtual bool SupportsCookieContainer => true;
771
772 public override bool UseDefaultCredentials
773 {
774 get
775 {
777 }
778 set
779 {
781 {
783 }
785 }
786 }
787
788 public override IWebProxy? Proxy
789 {
790 get
791 {
792 return _proxy;
793 }
794 set
795 {
797 {
799 }
800 _proxy = value;
801 }
802 }
803
804 private bool IsVersionHttp10
805 {
806 get
807 {
808 return (_booleans & Booleans.IsVersionHttp10) != 0;
809 }
810 set
811 {
812 if (value)
813 {
814 _booleans |= Booleans.IsVersionHttp10;
815 }
816 else
817 {
818 _booleans &= ~Booleans.IsVersionHttp10;
819 }
820 }
821 }
822
823 private bool RequestSubmitted => _sendRequestTask != null;
824
825 [Obsolete("WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.", DiagnosticId = "SYSLIB0014", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
831
836
841
842 internal HttpWebRequest(Uri uri)
843 {
844 _requestUri = uri;
845 }
846
847 private void SetSpecialHeaders(string HeaderName, string value)
848 {
849 _webHeaderCollection.Remove(HeaderName);
850 if (!string.IsNullOrEmpty(value))
851 {
852 _webHeaderCollection[HeaderName] = value;
853 }
854 }
855
856 public override void Abort()
857 {
859 {
860 return;
861 }
862 if (_responseOperation != null)
863 {
864 if (_responseOperation.TrySetCanceled() && _responseCallback != null)
865 {
867 }
869 }
871 {
873 }
874 }
875
876 public override WebResponse GetResponse()
877 {
878 try
879 {
881 return SendRequest(async: false).GetAwaiter().GetResult();
882 }
883 catch (Exception exception)
884 {
886 }
887 }
888
889 public override Stream GetRequestStream()
890 {
891 return InternalGetRequestStream().Result;
892 }
893
895 {
896 CheckAbort();
897 if (string.Equals(HttpMethod.Get.Method, _originVerb, StringComparison.OrdinalIgnoreCase) || string.Equals(HttpMethod.Head.Method, _originVerb, StringComparison.OrdinalIgnoreCase) || string.Equals("CONNECT", _originVerb, StringComparison.OrdinalIgnoreCase))
898 {
900 }
902 {
904 }
906 return Task.FromResult((Stream)_requestStream);
907 }
908
910 {
911 context = null;
913 }
914
916 {
917 context = null;
918 return GetRequestStream();
919 }
920
921 public override IAsyncResult BeginGetRequestStream(AsyncCallback? callback, object? state)
922 {
923 CheckAbort();
925 {
927 }
928 _requestStreamCallback = callback;
931 }
932
934 {
935 CheckAbort();
936 if (asyncResult == null || !(asyncResult is Task<Stream>))
937 {
938 throw new ArgumentException(System.SR.net_io_invalidasyncresult, "asyncResult");
939 }
941 {
942 throw new InvalidOperationException(System.SR.Format(System.SR.net_io_invalidendcall, "EndGetRequestStream"));
943 }
944 try
945 {
946 return ((Task<Stream>)asyncResult).GetAwaiter().GetResult();
947 }
948 catch (Exception exception)
949 {
951 }
952 }
953
955 {
957 {
959 }
961 bool disposeRequired = false;
962 HttpClient client = null;
963 try
964 {
966 if (_requestStream != null)
967 {
970 }
971 if (_hostUri != null)
972 {
974 }
975 foreach (string item in _webHeaderCollection)
976 {
978 {
979 if (httpRequestMessage.Content == null)
980 {
982 }
983 httpRequestMessage.Content.Headers.TryAddWithoutValidation(item, _webHeaderCollection[item]);
984 }
985 else
986 {
987 httpRequestMessage.Headers.TryAddWithoutValidation(item, _webHeaderCollection[item]);
988 }
989 }
991 if (KeepAlive)
992 {
993 httpRequestMessage.Headers.Connection.Add("Keep-Alive");
994 }
995 else
996 {
998 }
1002 int num = (AllowAutoRedirect ? 299 : 399);
1004 {
1005 throw new WebException(System.SR.Format(System.SR.net_servererror, (int)httpWebResponse.StatusCode, httpWebResponse.StatusDescription), null, WebExceptionStatus.ProtocolError, httpWebResponse);
1006 }
1007 return httpWebResponse;
1008 }
1009 finally
1010 {
1011 if (disposeRequired)
1012 {
1013 client?.Dispose();
1014 }
1015 }
1016 }
1017
1018 public override IAsyncResult BeginGetResponse(AsyncCallback? callback, object? state)
1019 {
1020 CheckAbort();
1022 {
1024 }
1026 _responseCallback = callback;
1027 _responseOperation = SendRequest(async: true).ToApm(callback, state);
1028 return _responseOperation.Task;
1029 }
1030
1032 {
1033 CheckAbort();
1034 if (asyncResult == null || !(asyncResult is Task<WebResponse>))
1035 {
1036 throw new ArgumentException(System.SR.net_io_invalidasyncresult, "asyncResult");
1037 }
1039 {
1041 }
1042 try
1043 {
1044 return ((Task<WebResponse>)asyncResult).GetAwaiter().GetResult();
1045 }
1046 catch (Exception exception)
1047 {
1049 }
1050 }
1051
1052 public void AddRange(int from, int to)
1053 {
1054 AddRange("bytes", (long)from, (long)to);
1055 }
1056
1057 public void AddRange(long from, long to)
1058 {
1059 AddRange("bytes", from, to);
1060 }
1061
1062 public void AddRange(int range)
1063 {
1064 AddRange("bytes", (long)range);
1065 }
1066
1067 public void AddRange(long range)
1068 {
1069 AddRange("bytes", range);
1070 }
1071
1072 public void AddRange(string rangeSpecifier, int from, int to)
1073 {
1074 AddRange(rangeSpecifier, (long)from, (long)to);
1075 }
1076
1077 public void AddRange(string rangeSpecifier, long from, long to)
1078 {
1079 if (rangeSpecifier == null)
1080 {
1081 throw new ArgumentNullException("rangeSpecifier");
1082 }
1083 if (from < 0 || to < 0)
1084 {
1085 throw new ArgumentOutOfRangeException((from < 0) ? "from" : "to", System.SR.net_rangetoosmall);
1086 }
1087 if (from > to)
1088 {
1090 }
1092 {
1093 throw new ArgumentException(System.SR.net_nottoken, "rangeSpecifier");
1094 }
1096 {
1098 }
1099 }
1100
1101 public void AddRange(string rangeSpecifier, int range)
1102 {
1104 }
1105
1106 public void AddRange(string rangeSpecifier, long range)
1107 {
1108 if (rangeSpecifier == null)
1109 {
1110 throw new ArgumentNullException("rangeSpecifier");
1111 }
1113 {
1114 throw new ArgumentException(System.SR.net_nottoken, "rangeSpecifier");
1115 }
1116 if (!AddRange(rangeSpecifier, range.ToString(NumberFormatInfo.InvariantInfo), (range >= 0) ? "" : null))
1117 {
1119 }
1120 }
1121
1122 private bool AddRange(string rangeSpecifier, string from, string to)
1123 {
1124 string text = _webHeaderCollection["Range"];
1125 if (text == null || text.Length == 0)
1126 {
1127 text = rangeSpecifier + "=";
1128 }
1129 else
1130 {
1131 if (!string.Equals(text.Substring(0, text.IndexOf('=')), rangeSpecifier, StringComparison.OrdinalIgnoreCase))
1132 {
1133 return false;
1134 }
1135 text = string.Empty;
1136 }
1137 text += from.ToString();
1138 if (to != null)
1139 {
1140 text = text + "-" + to;
1141 }
1142 _webHeaderCollection["Range"] = text;
1143 return true;
1144 }
1145
1146 private void CheckAbort()
1147 {
1148 if (Volatile.Read(ref _abortCalled) == 1)
1149 {
1150 throw new WebException(System.SR.net_reqaborted, WebExceptionStatus.RequestCanceled);
1151 }
1152 }
1153
1155 {
1157 foreach (string b in array)
1158 {
1159 if (string.Equals(header, b, StringComparison.OrdinalIgnoreCase))
1160 {
1161 return true;
1162 }
1163 }
1164 return false;
1165 }
1166
1168 {
1170 if (text == null)
1171 {
1172 return DateTime.MinValue;
1173 }
1175 {
1176 return result.LocalDateTime;
1177 }
1179 }
1180
1182 {
1183 if (dateTime == DateTime.MinValue)
1184 {
1186 }
1187 else
1188 {
1190 }
1191 }
1192
1193 private bool TryGetHostUri(string hostName, [NotNullWhen(true)] out Uri hostUri)
1194 {
1195 string uriString = Address.Scheme + "://" + hostName + Address.PathAndQuery;
1196 return Uri.TryCreate(uriString, UriKind.Absolute, out hostUri);
1197 }
1198
1200 {
1202 if (httpClientParameters.AreParametersAcceptableForCaching())
1203 {
1204 disposeRequired = false;
1205 if (s_cachedHttpClient == null)
1206 {
1208 {
1209 if (s_cachedHttpClient == null)
1210 {
1213 return s_cachedHttpClient;
1214 }
1215 }
1216 }
1218 {
1219 return s_cachedHttpClient;
1220 }
1221 }
1222 disposeRequired = true;
1224 }
1225
1227 {
1228 HttpClient httpClient = null;
1229 try
1230 {
1239 httpClient.Timeout = parameters.Timeout;
1240 if (parameters.CookieContainer != null)
1241 {
1243 }
1244 else
1245 {
1247 }
1248 if (parameters.Proxy == null)
1249 {
1251 }
1252 else if (parameters.Proxy != WebRequest.GetSystemWebProxy())
1253 {
1254 socketsHttpHandler.Proxy = parameters.Proxy;
1255 }
1256 else
1257 {
1259 }
1260 if (parameters.ClientCertificates != null)
1261 {
1263 }
1266 RemoteCertificateValidationCallback rcvc = parameters.ServerCertificateValidationCallback;
1267 if (rcvc != null)
1268 {
1270 }
1272 {
1273 Socket socket = new Socket(SocketType.Stream, ProtocolType.Tcp);
1274 try
1275 {
1276 socket.NoDelay = true;
1277 if (parameters.Async)
1278 {
1279 await socket.ConnectAsync(context.DnsEndPoint, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
1280 }
1281 else
1282 {
1283 using (cancellationToken.UnsafeRegister(delegate(object s)
1284 {
1285 ((Socket)s).Dispose();
1286 }, socket))
1287 {
1288 socket.Connect(context.DnsEndPoint);
1289 }
1290 cancellationToken.ThrowIfCancellationRequested();
1291 }
1292 if (parameters.ReadWriteTimeout > 0)
1293 {
1296 }
1297 }
1298 catch
1299 {
1300 socket.Dispose();
1301 throw;
1302 }
1303 return new NetworkStream(socket, ownsSocket: true);
1304 };
1305 return httpClient;
1306 }
1307 catch
1308 {
1310 throw;
1311 }
1312 }
1313}
static ICredentials DefaultCredentials
static string DateToString(DateTimeOffset dateTime)
static bool TryParse(ReadOnlySpan< char > input, out DateTimeOffset result)
static string CheckBadHeaderValueChars(string value)
static bool IsValidToken(string token)
static bool IsInvalidMethodOrHeaderString(string stringValue)
static readonly Version Version10
Definition HttpVersion.cs:7
static readonly Version Version11
Definition HttpVersion.cs:9
readonly X509CertificateCollection ClientCertificates
readonly RemoteCertificateValidationCallback ServerCertificateValidationCallback
readonly DecompressionMethods AutomaticDecompression
HttpClientParameters(HttpWebRequest webRequest, bool async)
bool Matches(HttpClientParameters requestParameters)
readonly SecurityProtocolType SslProtocols
override IAsyncResult BeginGetRequestStream(AsyncCallback? callback, object? state)
AsyncCallback _requestStreamCallback
Stream EndGetRequestStream(IAsyncResult asyncResult, out TransportContext? context)
override bool UseDefaultCredentials
override Stream GetRequestStream()
TaskCompletionSource< Stream > _requestStreamOperation
Task< Stream > InternalGetRequestStream()
override WebResponse EndGetResponse(IAsyncResult asyncResult)
void AddRange(string rangeSpecifier, long range)
virtual bool AllowWriteStreamBuffering
CancellationTokenSource _sendRequestCts
void AddRange(int from, int to)
static int DefaultMaximumResponseHeadersLength
static volatile HttpClient s_cachedHttpClient
void AddRange(string rangeSpecifier, long from, long to)
override IAsyncResult BeginGetResponse(AsyncCallback? callback, object? state)
void AddRange(string rangeSpecifier, int range)
void SetDateHeaderHelper(string headerName, DateTime dateTime)
virtual bool SupportsCookieContainer
override? ICredentials Credentials
static HttpClientParameters s_cachedHttpClientParameters
static int DefaultMaximumErrorResponseLength
HttpContinueDelegate? ContinueDelegate
X509CertificateCollection _clientCertificates
DecompressionMethods _automaticDecompression
override WebResponse GetResponse()
static new? RequestCachePolicy DefaultCachePolicy
override? string ConnectionGroupName
WebHeaderCollection _webHeaderCollection
static readonly object s_syncRoot
bool IsWellKnownContentHeader(string header)
HttpContinueDelegate _continueDelegate
Stream GetRequestStream(out TransportContext? context)
void AddRange(long from, long to)
bool AddRange(string rangeSpecifier, string from, string to)
void AddRange(string rangeSpecifier, int from, int to)
async Task< WebResponse > SendRequest(bool async)
bool TryGetHostUri(string hostName, [NotNullWhen(true)] out Uri hostUri)
override Stream EndGetRequestStream(IAsyncResult asyncResult)
void SetSpecialHeaders(string HeaderName, string value)
override? string ContentType
static readonly string[] s_wellKnownContentHeaders
static int _defaultMaxResponseHeadersLength
static HttpClient CreateHttpClient(HttpClientParameters parameters, HttpWebRequest request)
CookieContainer _cookieContainer
override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext)
HttpClient GetCachedOrCreateHttpClient(bool async, out bool disposeRequired)
HttpWebRequest(SerializationInfo serializationInfo, StreamingContext streamingContext)
RemoteCertificateValidationCallback? ServerCertificateValidationCallback
TaskCompletionSource< WebResponse > _responseOperation
Task< HttpResponseMessage > _sendRequestTask
X509CertificateCollection ClientCertificates
override? IWebProxy Proxy
DateTime GetDateHeaderHelper(string headerName)
virtual bool AllowReadStreamBuffering
DecompressionMethods AutomaticDecompression
static HttpMethod Head
Definition HttpMethod.cs:43
static HttpMethod Get
Definition HttpMethod.cs:35
ArraySegment< byte > GetBuffer()
static ? RemoteCertificateValidationCallback ServerCertificateValidationCallback
static SecurityProtocolType SecurityProtocol
static ServicePoint FindServicePoint(Uri address)
override void Dispose(bool disposing)
static Exception CreateCompatibleException(Exception exception)
void Remove(HttpRequestHeader header)
static IWebProxy GetSystemWebProxy()
static ? IWebProxy DefaultWebProxy
static string net_servererror
Definition SR.cs:28
static string net_rangetoosmall
Definition SR.cs:62
static string net_nottoken
Definition SR.cs:60
static string net_nochunked
Definition SR.cs:58
static string net_reqsubmitted
Definition SR.cs:16
static string net_io_invalidendcall
Definition SR.cs:22
static string net_rangetype
Definition SR.cs:64
static string net_writestarted
Definition SR.cs:20
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string net_reqaborted
Definition SR.cs:30
static string net_needchunked
Definition SR.cs:54
static string net_no100
Definition SR.cs:56
static string net_io_timeout_use_gt_zero
Definition SR.cs:80
static string net_nouploadonget
Definition SR.cs:36
static string net_clsmall
Definition SR.cs:110
static string net_invalid_host
Definition SR.cs:144
static string net_badmethod
Definition SR.cs:22
static string net_connarg
Definition SR.cs:50
static string net_io_timeout_use_ge_zero
Definition SR.cs:18
static string net_io_invalidasyncresult
Definition SR.cs:20
static string net_toosmall
Definition SR.cs:14
static string net_repcall
Definition SR.cs:38
static string net_wrongversion
Definition SR.cs:112
static string net_baddate
Definition SR.cs:48
static string net_fromto
Definition SR.cs:52
Definition SR.cs:7
static int Exchange(ref int location1, int value)
new ConfiguredTaskAwaitable< TResult > ConfigureAwait(bool continueOnCapturedContext)
Definition Task.cs:226
static readonly TimeSpan InfiniteTimeSpan
Definition Timeout.cs:5
static bool Read(ref bool location)
Definition Volatile.cs:67
string Host
Definition Uri.cs:441
string PathAndQuery
Definition Uri.cs:378
static bool TryCreate([NotNullWhen(true)] string? uriString, UriKind uriKind, [NotNullWhen(true)] out Uri? result)
Definition Uri.cs:3793
bool IsDefaultPort
Definition Uri.cs:333
int Port
Definition Uri.cs:453
ICredentials? Credentials
Definition IWebProxy.cs:5
void GetObjectData(SerializationInfo info, StreamingContext context)
UriKind
Definition UriKind.cs:4
static readonly DateTime MinValue
Definition DateTime.cs:35
static TimeSpan FromMilliseconds(double value)
Definition TimeSpan.cs:228