mscorlib(4.0.0.0) API with additions
WebRequest.cs
1 using System.Collections;
4 using System.IO;
5 using System.Net.Cache;
7 using System.Net.Security;
8 using System.Reflection;
10 using System.Security;
13 using System.Threading;
14 using System.Threading.Tasks;
15 
16 namespace System.Net
17 {
19  [Serializable]
20  [global::__DynamicallyInvokable]
21  public abstract class WebRequest : MarshalByRefObject, ISerializable
22  {
23  internal class DesignerWebRequestCreate : IWebRequestCreate
24  {
25  public WebRequest Create(Uri uri)
26  {
27  return WebRequest.Create(uri);
28  }
29  }
30 
31  internal class WebProxyWrapperOpaque : IAutoWebProxy, IWebProxy
32  {
33  protected readonly WebProxy webProxy;
34 
36  {
37  get
38  {
39  return webProxy.Credentials;
40  }
41  set
42  {
43  webProxy.Credentials = value;
44  }
45  }
46 
47  internal WebProxyWrapperOpaque(WebProxy webProxy)
48  {
49  this.webProxy = webProxy;
50  }
51 
52  public Uri GetProxy(Uri destination)
53  {
54  return webProxy.GetProxy(destination);
55  }
56 
57  public bool IsBypassed(Uri host)
58  {
59  return webProxy.IsBypassed(host);
60  }
61 
62  public ProxyChain GetProxies(Uri destination)
63  {
64  return ((IAutoWebProxy)webProxy).GetProxies(destination);
65  }
66  }
67 
68  internal class WebProxyWrapper : WebProxyWrapperOpaque
69  {
70  internal WebProxy WebProxy => webProxy;
71 
72  internal WebProxyWrapper(WebProxy webProxy)
73  : base(webProxy)
74  {
75  }
76  }
77 
78  private delegate void DelEtwFireBeginWRGet(object id, string uri, bool success, bool synchronous);
79 
80  private delegate void DelEtwFireEndWRGet(object id, bool success, bool synchronous);
81 
82  private delegate void DelEtwFireEndWRespGet(object id, bool success, bool synchronous, int statusCode);
83 
84  internal const int DefaultTimeout = 100000;
85 
86  private static volatile ArrayList s_PrefixList;
87 
88  private static object s_InternalSyncObject;
89 
90  private static TimerThread.Queue s_DefaultTimerQueue = TimerThread.CreateQueue(100000);
91 
92  private AuthenticationLevel m_AuthenticationLevel;
93 
94  private TokenImpersonationLevel m_ImpersonationLevel;
95 
96  private RequestCachePolicy m_CachePolicy;
97 
98  private RequestCacheProtocol m_CacheProtocol;
99 
100  private RequestCacheBinding m_CacheBinding;
101 
102  private static DesignerWebRequestCreate webRequestCreate = new DesignerWebRequestCreate();
103 
104  private static volatile IWebProxy s_DefaultWebProxy;
105 
106  private static volatile bool s_DefaultWebProxyInitialized;
107 
108  private static DelEtwFireBeginWRGet s_EtwFireBeginGetResponse;
109 
110  private static DelEtwFireEndWRespGet s_EtwFireEndGetResponse;
111 
112  private static DelEtwFireBeginWRGet s_EtwFireBeginGetRequestStream;
113 
114  private static DelEtwFireEndWRGet s_EtwFireEndGetRequestStream;
115 
116  private static volatile bool s_TriedGetEtwDelegates;
117 
120  [Obsolete("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
121  [EditorBrowsable(EditorBrowsableState.Never)]
122  public virtual IWebRequestCreate CreatorInstance
123  {
124  get
125  {
126  return webRequestCreate;
127  }
128  }
129 
130  private static object InternalSyncObject
131  {
132  get
133  {
134  if (s_InternalSyncObject == null)
135  {
136  object value = new object();
137  Interlocked.CompareExchange(ref s_InternalSyncObject, value, null);
138  }
139  return s_InternalSyncObject;
140  }
141  }
142 
143  internal static TimerThread.Queue DefaultTimerQueue => s_DefaultTimerQueue;
144 
145  internal static ArrayList PrefixList
146  {
147  get
148  {
149  if (s_PrefixList == null)
150  {
151  lock (InternalSyncObject)
152  {
153  if (s_PrefixList == null)
154  {
155  s_PrefixList = WebRequestModulesSectionInternal.GetSection().WebRequestModules;
156  }
157  }
158  }
159  return s_PrefixList;
160  }
161  set
162  {
163  s_PrefixList = value;
164  }
165  }
166 
170  {
171  get
172  {
173  return RequestCacheManager.GetBinding(string.Empty).Policy;
174  }
175  set
176  {
177  ExceptionHelper.WebPermissionUnrestricted.Demand();
178  RequestCacheBinding binding = RequestCacheManager.GetBinding(string.Empty);
179  RequestCacheManager.SetBinding(string.Empty, new RequestCacheBinding(binding.Cache, binding.Validator, value));
180  }
181  }
182 
185  public virtual RequestCachePolicy CachePolicy
186  {
187  get
188  {
189  return m_CachePolicy;
190  }
191  set
192  {
193  InternalSetCachePolicy(value);
194  }
195  }
196 
200  [global::__DynamicallyInvokable]
201  public virtual string Method
202  {
203  [global::__DynamicallyInvokable]
204  get
205  {
206  throw ExceptionHelper.PropertyNotImplementedException;
207  }
208  [global::__DynamicallyInvokable]
209  set
210  {
211  throw ExceptionHelper.PropertyNotImplementedException;
212  }
213  }
214 
218  [global::__DynamicallyInvokable]
219  public virtual Uri RequestUri
220  {
221  [global::__DynamicallyInvokable]
222  get
223  {
224  throw ExceptionHelper.PropertyNotImplementedException;
225  }
226  }
227 
231  public virtual string ConnectionGroupName
232  {
233  get
234  {
235  throw ExceptionHelper.PropertyNotImplementedException;
236  }
237  set
238  {
239  throw ExceptionHelper.PropertyNotImplementedException;
240  }
241  }
242 
246  [global::__DynamicallyInvokable]
247  public virtual WebHeaderCollection Headers
248  {
249  [global::__DynamicallyInvokable]
250  get
251  {
252  throw ExceptionHelper.PropertyNotImplementedException;
253  }
254  [global::__DynamicallyInvokable]
255  set
256  {
257  throw ExceptionHelper.PropertyNotImplementedException;
258  }
259  }
260 
264  public virtual long ContentLength
265  {
266  get
267  {
268  throw ExceptionHelper.PropertyNotImplementedException;
269  }
270  set
271  {
272  throw ExceptionHelper.PropertyNotImplementedException;
273  }
274  }
275 
279  [global::__DynamicallyInvokable]
280  public virtual string ContentType
281  {
282  [global::__DynamicallyInvokable]
283  get
284  {
285  throw ExceptionHelper.PropertyNotImplementedException;
286  }
287  [global::__DynamicallyInvokable]
288  set
289  {
290  throw ExceptionHelper.PropertyNotImplementedException;
291  }
292  }
293 
297  [global::__DynamicallyInvokable]
298  public virtual ICredentials Credentials
299  {
300  [global::__DynamicallyInvokable]
301  get
302  {
303  throw ExceptionHelper.PropertyNotImplementedException;
304  }
305  [global::__DynamicallyInvokable]
306  set
307  {
308  throw ExceptionHelper.PropertyNotImplementedException;
309  }
310  }
311 
317  [global::__DynamicallyInvokable]
318  public virtual bool UseDefaultCredentials
319  {
320  [global::__DynamicallyInvokable]
321  get
322  {
323  throw ExceptionHelper.PropertyNotImplementedException;
324  }
325  [global::__DynamicallyInvokable]
326  set
327  {
328  throw ExceptionHelper.PropertyNotImplementedException;
329  }
330  }
331 
335  [global::__DynamicallyInvokable]
336  public virtual IWebProxy Proxy
337  {
338  [global::__DynamicallyInvokable]
339  get
340  {
341  throw ExceptionHelper.PropertyNotImplementedException;
342  }
343  [global::__DynamicallyInvokable]
344  set
345  {
346  throw ExceptionHelper.PropertyNotImplementedException;
347  }
348  }
349 
354  public virtual bool PreAuthenticate
355  {
356  get
357  {
358  throw ExceptionHelper.PropertyNotImplementedException;
359  }
360  set
361  {
362  throw ExceptionHelper.PropertyNotImplementedException;
363  }
364  }
365 
369  public virtual int Timeout
370  {
371  get
372  {
373  throw ExceptionHelper.PropertyNotImplementedException;
374  }
375  set
376  {
377  throw ExceptionHelper.PropertyNotImplementedException;
378  }
379  }
380 
381  internal RequestCacheProtocol CacheProtocol
382  {
383  get
384  {
385  return m_CacheProtocol;
386  }
387  set
388  {
389  m_CacheProtocol = value;
390  }
391  }
392 
396  {
397  get
398  {
399  return m_AuthenticationLevel;
400  }
401  set
402  {
403  m_AuthenticationLevel = value;
404  }
405  }
406 
410  {
411  get
412  {
413  return m_ImpersonationLevel;
414  }
415  set
416  {
417  m_ImpersonationLevel = value;
418  }
419  }
420 
421  internal static IWebProxy InternalDefaultWebProxy
422  {
423  get
424  {
425  if (!s_DefaultWebProxyInitialized)
426  {
427  lock (InternalSyncObject)
428  {
429  if (!s_DefaultWebProxyInitialized)
430  {
431  DefaultProxySectionInternal section = DefaultProxySectionInternal.GetSection();
432  if (section != null)
433  {
434  s_DefaultWebProxy = section.WebProxy;
435  }
436  s_DefaultWebProxyInitialized = true;
437  }
438  }
439  }
440  return s_DefaultWebProxy;
441  }
442  set
443  {
444  if (!s_DefaultWebProxyInitialized)
445  {
446  lock (InternalSyncObject)
447  {
448  s_DefaultWebProxy = value;
449  s_DefaultWebProxyInitialized = true;
450  }
451  }
452  else
453  {
454  s_DefaultWebProxy = value;
455  }
456  }
457  }
458 
461  [global::__DynamicallyInvokable]
462  public static IWebProxy DefaultWebProxy
463  {
464  [global::__DynamicallyInvokable]
465  get
466  {
467  ExceptionHelper.WebPermissionUnrestricted.Demand();
468  return InternalDefaultWebProxy;
469  }
470  [global::__DynamicallyInvokable]
471  set
472  {
473  ExceptionHelper.WebPermissionUnrestricted.Demand();
474  InternalDefaultWebProxy = value;
475  }
476  }
477 
480  [Obsolete("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
481  [EditorBrowsable(EditorBrowsableState.Never)]
483  {
484  }
485 
486  private static WebRequest Create(Uri requestUri, bool useUriBase)
487  {
488  if (Logging.On)
489  {
490  Logging.Enter(Logging.Web, "WebRequest", "Create", requestUri.ToString());
491  }
492  WebRequestPrefixElement webRequestPrefixElement = null;
493  bool flag = false;
494  string text = useUriBase ? (requestUri.Scheme + ":") : requestUri.AbsoluteUri;
495  int length = text.Length;
496  ArrayList prefixList = PrefixList;
497  for (int i = 0; i < prefixList.Count; i++)
498  {
499  webRequestPrefixElement = (WebRequestPrefixElement)prefixList[i];
500  if (length >= webRequestPrefixElement.Prefix.Length && string.Compare(webRequestPrefixElement.Prefix, 0, text, 0, webRequestPrefixElement.Prefix.Length, StringComparison.OrdinalIgnoreCase) == 0)
501  {
502  flag = true;
503  break;
504  }
505  }
506  WebRequest webRequest = null;
507  if (flag)
508  {
509  webRequest = webRequestPrefixElement.Creator.Create(requestUri);
510  if (Logging.On)
511  {
512  Logging.Exit(Logging.Web, "WebRequest", "Create", webRequest);
513  }
514  return webRequest;
515  }
516  if (Logging.On)
517  {
518  Logging.Exit(Logging.Web, "WebRequest", "Create", null);
519  }
520  throw new NotSupportedException(SR.GetString("net_unknown_prefix"));
521  }
522 
532  [global::__DynamicallyInvokable]
533  public static WebRequest Create(string requestUriString)
534  {
535  if (requestUriString == null)
536  {
537  throw new ArgumentNullException("requestUriString");
538  }
539  return Create(new Uri(requestUriString), useUriBase: false);
540  }
541 
549  [global::__DynamicallyInvokable]
550  public static WebRequest Create(Uri requestUri)
551  {
552  if (requestUri == null)
553  {
554  throw new ArgumentNullException("requestUri");
555  }
556  return Create(requestUri, useUriBase: false);
557  }
558 
566  public static WebRequest CreateDefault(Uri requestUri)
567  {
568  if (requestUri == null)
569  {
570  throw new ArgumentNullException("requestUri");
571  }
572  return Create(requestUri, useUriBase: true);
573  }
574 
583  [global::__DynamicallyInvokable]
584  public static HttpWebRequest CreateHttp(string requestUriString)
585  {
586  if (requestUriString == null)
587  {
588  throw new ArgumentNullException("requestUriString");
589  }
590  return CreateHttp(new Uri(requestUriString));
591  }
592 
601  [global::__DynamicallyInvokable]
602  public static HttpWebRequest CreateHttp(Uri requestUri)
603  {
604  if (requestUri == null)
605  {
606  throw new ArgumentNullException("requestUri");
607  }
608  if (requestUri.Scheme != Uri.UriSchemeHttp && requestUri.Scheme != Uri.UriSchemeHttps)
609  {
610  throw new NotSupportedException(SR.GetString("net_unknown_prefix"));
611  }
612  return (HttpWebRequest)CreateDefault(requestUri);
613  }
614 
623  [global::__DynamicallyInvokable]
624  public static bool RegisterPrefix(string prefix, IWebRequestCreate creator)
625  {
626  bool flag = false;
627  if (prefix == null)
628  {
629  throw new ArgumentNullException("prefix");
630  }
631  if (creator == null)
632  {
633  throw new ArgumentNullException("creator");
634  }
635  ExceptionHelper.WebPermissionUnrestricted.Demand();
636  lock (InternalSyncObject)
637  {
638  ArrayList arrayList = (ArrayList)PrefixList.Clone();
639  if (Uri.TryCreate(prefix, UriKind.Absolute, out Uri result))
640  {
641  string text = result.AbsoluteUri;
642  if (!prefix.EndsWith("/", StringComparison.Ordinal) && result.GetComponents(UriComponents.Path | UriComponents.Query | UriComponents.Fragment, UriFormat.UriEscaped).Equals("/"))
643  {
644  text = text.Substring(0, text.Length - 1);
645  }
646  prefix = text;
647  }
648  int i;
649  for (i = 0; i < arrayList.Count; i++)
650  {
651  WebRequestPrefixElement webRequestPrefixElement = (WebRequestPrefixElement)arrayList[i];
652  if (prefix.Length > webRequestPrefixElement.Prefix.Length)
653  {
654  break;
655  }
656  if (prefix.Length == webRequestPrefixElement.Prefix.Length && string.Compare(webRequestPrefixElement.Prefix, prefix, StringComparison.OrdinalIgnoreCase) == 0)
657  {
658  flag = true;
659  break;
660  }
661  }
662  if (!flag)
663  {
664  arrayList.Insert(i, new WebRequestPrefixElement(prefix, creator));
665  PrefixList = arrayList;
666  }
667  }
668  return !flag;
669  }
670 
672  [global::__DynamicallyInvokable]
673  protected WebRequest()
674  {
675  m_ImpersonationLevel = TokenImpersonationLevel.Delegation;
676  m_AuthenticationLevel = AuthenticationLevel.MutualAuthRequested;
677  }
678 
683  protected WebRequest(SerializationInfo serializationInfo, StreamingContext streamingContext)
684  {
685  }
686 
691  [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter, SerializationFormatter = true)]
692  void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext)
693  {
694  GetObjectData(serializationInfo, streamingContext);
695  }
696 
700  [SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)]
701  protected virtual void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext)
702  {
703  }
704 
705  private void InternalSetCachePolicy(RequestCachePolicy policy)
706  {
707  if (m_CacheBinding != null && m_CacheBinding.Cache != null && m_CacheBinding.Validator != null && CacheProtocol == null && policy != null && policy.Level != RequestCacheLevel.BypassCache)
708  {
709  CacheProtocol = new RequestCacheProtocol(m_CacheBinding.Cache, m_CacheBinding.Validator.CreateValidator());
710  }
711  m_CachePolicy = policy;
712  }
713 
717  public virtual Stream GetRequestStream()
718  {
719  throw ExceptionHelper.MethodNotImplementedException;
720  }
721 
725  public virtual WebResponse GetResponse()
726  {
727  throw ExceptionHelper.MethodNotImplementedException;
728  }
729 
735  [global::__DynamicallyInvokable]
736  [HostProtection(SecurityAction.LinkDemand, ExternalThreading = true)]
737  public virtual IAsyncResult BeginGetResponse(AsyncCallback callback, object state)
738  {
739  throw ExceptionHelper.MethodNotImplementedException;
740  }
741 
746  [global::__DynamicallyInvokable]
747  public virtual WebResponse EndGetResponse(IAsyncResult asyncResult)
748  {
749  throw ExceptionHelper.MethodNotImplementedException;
750  }
751 
757  [global::__DynamicallyInvokable]
758  [HostProtection(SecurityAction.LinkDemand, ExternalThreading = true)]
759  public virtual IAsyncResult BeginGetRequestStream(AsyncCallback callback, object state)
760  {
761  throw ExceptionHelper.MethodNotImplementedException;
762  }
763 
768  [global::__DynamicallyInvokable]
769  public virtual Stream EndGetRequestStream(IAsyncResult asyncResult)
770  {
771  throw ExceptionHelper.MethodNotImplementedException;
772  }
773 
776  [global::__DynamicallyInvokable]
777  [HostProtection(SecurityAction.LinkDemand, ExternalThreading = true)]
779  {
780  IWebProxy webProxy = null;
781  try
782  {
783  webProxy = Proxy;
784  }
786  {
787  }
788  if (ExecutionContext.IsFlowSuppressed() && (UseDefaultCredentials || Credentials != null || (webProxy != null && webProxy.Credentials != null)))
789  {
790  WindowsIdentity currentUser = SafeCaptureIdenity();
791  return Task.Run(delegate
792  {
793  using (currentUser)
794  {
795  using (currentUser.Impersonate())
796  {
798  WebRequest webRequest = this;
799  Func<AsyncCallback, object, IAsyncResult> beginMethod = webRequest.BeginGetRequestStream;
800  WebRequest webRequest2 = this;
801  return factory.FromAsync(beginMethod, webRequest2.EndGetRequestStream, null);
802  }
803  }
804  });
805  }
806  return Task.Run(() => Task<Stream>.Factory.FromAsync(BeginGetRequestStream, EndGetRequestStream, null));
807  }
808 
811  [global::__DynamicallyInvokable]
812  [HostProtection(SecurityAction.LinkDemand, ExternalThreading = true)]
814  {
815  IWebProxy webProxy = null;
816  try
817  {
818  webProxy = Proxy;
819  }
821  {
822  }
823  if (ExecutionContext.IsFlowSuppressed() && (UseDefaultCredentials || Credentials != null || (webProxy != null && webProxy.Credentials != null)))
824  {
825  WindowsIdentity currentUser = SafeCaptureIdenity();
826  return Task.Run(delegate
827  {
828  using (currentUser)
829  {
830  using (currentUser.Impersonate())
831  {
833  WebRequest webRequest = this;
834  Func<AsyncCallback, object, IAsyncResult> beginMethod = webRequest.BeginGetResponse;
835  WebRequest webRequest2 = this;
836  return factory.FromAsync(beginMethod, webRequest2.EndGetResponse, null);
837  }
838  }
839  });
840  }
841  return Task.Run(() => Task<WebResponse>.Factory.FromAsync(BeginGetResponse, EndGetResponse, null));
842  }
843 
844  [SecuritySafeCritical]
845  [SecurityPermission(SecurityAction.Assert, Flags = SecurityPermissionFlag.ControlPrincipal)]
846  private WindowsIdentity SafeCaptureIdenity()
847  {
848  return WindowsIdentity.GetCurrent();
849  }
850 
853  [global::__DynamicallyInvokable]
854  public virtual void Abort()
855  {
856  throw ExceptionHelper.MethodNotImplementedException;
857  }
858 
859  internal virtual ContextAwareResult GetConnectingContext()
860  {
861  throw ExceptionHelper.MethodNotImplementedException;
862  }
863 
864  internal virtual ContextAwareResult GetWritingContext()
865  {
866  throw ExceptionHelper.MethodNotImplementedException;
867  }
868 
869  internal virtual ContextAwareResult GetReadingContext()
870  {
871  throw ExceptionHelper.MethodNotImplementedException;
872  }
873 
874  internal virtual void RequestCallback(object obj)
875  {
876  throw ExceptionHelper.MethodNotImplementedException;
877  }
878 
881  public static IWebProxy GetSystemWebProxy()
882  {
883  ExceptionHelper.WebPermissionUnrestricted.Demand();
884  return InternalGetSystemWebProxy();
885  }
886 
887  internal static IWebProxy InternalGetSystemWebProxy()
888  {
889  return new WebProxyWrapperOpaque(new WebProxy(enableAutoproxy: true));
890  }
891 
892  internal void SetupCacheProtocol(Uri uri)
893  {
894  m_CacheBinding = RequestCacheManager.GetBinding(uri.Scheme);
895  InternalSetCachePolicy(m_CacheBinding.Policy);
896  if (m_CachePolicy == null)
897  {
898  InternalSetCachePolicy(DefaultCachePolicy);
899  }
900  }
901 
902  private static void InitEtwMethods()
903  {
904  Type typeFromHandle = typeof(FrameworkEventSource);
905  Type[] types = new Type[4]
906  {
907  typeof(object),
908  typeof(string),
909  typeof(bool),
910  typeof(bool)
911  };
912  BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
913  MethodInfo method = typeFromHandle.GetMethod("BeginGetResponse", bindingAttr, null, types, null);
914  MethodInfo method2 = typeFromHandle.GetMethod("EndGetResponse", bindingAttr, null, new Type[4]
915  {
916  typeof(object),
917  typeof(bool),
918  typeof(bool),
919  typeof(int)
920  }, null);
921  MethodInfo method3 = typeFromHandle.GetMethod("BeginGetRequestStream", bindingAttr, null, types, null);
922  MethodInfo method4 = typeFromHandle.GetMethod("EndGetRequestStream", bindingAttr, null, new Type[3]
923  {
924  typeof(object),
925  typeof(bool),
926  typeof(bool)
927  }, null);
928  if (method != null && method2 != null && method3 != null && method4 != null)
929  {
930  s_EtwFireBeginGetResponse = (DelEtwFireBeginWRGet)method.CreateDelegate(typeof(DelEtwFireBeginWRGet), FrameworkEventSource.Log);
931  s_EtwFireEndGetResponse = (DelEtwFireEndWRespGet)method2.CreateDelegate(typeof(DelEtwFireEndWRespGet), FrameworkEventSource.Log);
932  s_EtwFireBeginGetRequestStream = (DelEtwFireBeginWRGet)method3.CreateDelegate(typeof(DelEtwFireBeginWRGet), FrameworkEventSource.Log);
933  s_EtwFireEndGetRequestStream = (DelEtwFireEndWRGet)method4.CreateDelegate(typeof(DelEtwFireEndWRGet), FrameworkEventSource.Log);
934  }
935  s_TriedGetEtwDelegates = true;
936  }
937 
938  internal void LogBeginGetResponse(bool success, bool synchronous)
939  {
940  string originalString = RequestUri.OriginalString;
941  if (!s_TriedGetEtwDelegates)
942  {
943  InitEtwMethods();
944  }
945  if (s_EtwFireBeginGetResponse != null)
946  {
947  s_EtwFireBeginGetResponse(this, originalString, success, synchronous);
948  }
949  }
950 
951  internal void LogEndGetResponse(bool success, bool synchronous, int statusCode)
952  {
953  if (!s_TriedGetEtwDelegates)
954  {
955  InitEtwMethods();
956  }
957  if (s_EtwFireEndGetResponse != null)
958  {
959  s_EtwFireEndGetResponse(this, success, synchronous, statusCode);
960  }
961  }
962 
963  internal void LogBeginGetRequestStream(bool success, bool synchronous)
964  {
965  string originalString = RequestUri.OriginalString;
966  if (!s_TriedGetEtwDelegates)
967  {
968  InitEtwMethods();
969  }
970  if (s_EtwFireBeginGetRequestStream != null)
971  {
972  s_EtwFireBeginGetRequestStream(this, originalString, success, synchronous);
973  }
974  }
975 
976  internal void LogEndGetRequestStream(bool success, bool synchronous)
977  {
978  if (!s_TriedGetEtwDelegates)
979  {
980  InitEtwMethods();
981  }
982  if (s_EtwFireEndGetRequestStream != null)
983  {
984  s_EtwFireEndGetRequestStream(this, success, synchronous);
985  }
986  }
987  }
988 }
UriKind
Defines the kinds of T:System.Uris for the M:System.Uri.IsWellFormedUriString(System....
Definition: UriKind.cs:5
TokenImpersonationLevel ImpersonationLevel
Gets or sets the impersonation level for the current request.
Definition: WebRequest.cs:410
static new TaskFactory< TResult > Factory
Provides access to factory methods for creating and configuring T:System.Threading....
Definition: Task.cs:75
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
Describes a set of security permissions applied to code. This class cannot be inherited.
static readonly string UriSchemeHttp
Specifies that the URI is accessed through the Hypertext Transfer Protocol (HTTP)....
Definition: Uri.cs:154
virtual Stream EndGetRequestStream(IAsyncResult asyncResult)
When overridden in a descendant class, returns a T:System.IO.Stream for writing data to the Internet ...
Definition: WebRequest.cs:769
virtual IAsyncResult BeginGetRequestStream(AsyncCallback callback, object state)
When overridden in a descendant class, provides an asynchronous version of the M:System....
Definition: WebRequest.cs:759
virtual WindowsImpersonationContext Impersonate()
Impersonates the user represented by the T:System.Security.Principal.WindowsIdentity object.
virtual void Insert(int index, object value)
Inserts an element into the T:System.Collections.ArrayList at the specified index.
Definition: ArrayList.cs:2698
Discovers the attributes of a method and provides access to method metadata.
Definition: MethodInfo.cs:13
virtual string ConnectionGroupName
When overridden in a descendant class, gets or sets the name of the connection group for the request.
Definition: WebRequest.cs:232
static WebRequest Create(string requestUriString)
Initializes a new T:System.Net.WebRequest instance for the specified URI scheme.
Definition: WebRequest.cs:533
StringComparison
Specifies the culture, case, and sort rules to be used by certain overloads of the M:System....
EditorBrowsableState
Specifies the browsable state of a property or method from within an editor.
virtual RequestCachePolicy CachePolicy
Gets or sets the cache policy for this request.
Definition: WebRequest.cs:186
string AbsoluteUri
Gets the absolute URI.
Definition: Uri.cs:344
virtual Task< Stream > GetRequestStreamAsync()
When overridden in a descendant class, returns a T:System.IO.Stream for writing data to the Internet ...
Definition: WebRequest.cs:778
Makes a request to a Uniform Resource Identifier (URI). This is an abstract class.
Definition: WebRequest.cs:21
virtual int Count
Gets the number of elements actually contained in the T:System.Collections.ArrayList.
Definition: ArrayList.cs:2255
BindingFlags
Specifies flags that control binding and the way in which the search for members and types is conduct...
Definition: BindingFlags.cs:10
Definition: __Canon.cs:3
string Scheme
Gets the scheme name for this URI.
Definition: Uri.cs:702
static WindowsIdentity GetCurrent()
Returns a T:System.Security.Principal.WindowsIdentity object that represents the current Windows user...
TokenImpersonationLevel
Defines security impersonation levels. Security impersonation levels govern the degree to which a ser...
RequestCacheLevel Level
Gets the T:System.Net.Cache.RequestCacheLevel value specified when this instance was constructed.
delegate void AsyncCallback(IAsyncResult ar)
References a method to be called when a corresponding asynchronous operation completes.
Specifies that the operating system should create a new file. If the file already exists,...
virtual object Clone()
Creates a shallow copy of the T:System.Collections.ArrayList.
Definition: ArrayList.cs:2473
Describes the source and destination of a given serialized stream, and provides an additional caller-...
static bool TryCreate(string uriString, UriKind uriKind, out Uri result)
Creates a new T:System.Uri using the specified T:System.String instance and a T:System....
Definition: Uri.cs:4782
virtual IWebRequestCreate CreatorInstance
When overridden in a descendant class, gets the factory object derived from the T:System....
Definition: WebRequest.cs:123
UriComponents
Specifies the parts of a T:System.Uri.
Definition: UriComponents.cs:6
static WebRequest Create(Uri requestUri)
Initializes a new T:System.Net.WebRequest instance for the specified URI scheme.
Definition: WebRequest.cs:550
Contains protocol headers associated with a request or response.
SecurityAction
Specifies the security actions that can be performed using declarative security.
virtual string ContentType
When overridden in a descendant class, gets or sets the content type of the request data being sent.
Definition: WebRequest.cs:281
Provides a response from a Uniform Resource Identifier (URI). This is an abstract class.
Definition: WebResponse.cs:10
Represents the status of an asynchronous operation.
Definition: IAsyncResult.cs:9
Manages the execution context for the current thread. This class cannot be inherited.
static WebRequest CreateDefault(Uri requestUri)
Initializes a new T:System.Net.WebRequest instance for the specified URI scheme.
Definition: WebRequest.cs:566
virtual Stream GetRequestStream()
When overridden in a descendant class, returns a T:System.IO.Stream for writing data to the Internet ...
Definition: WebRequest.cs:717
Provides the base interface for creating T:System.Net.WebRequest instances.
virtual string Method
When overridden in a descendant class, gets or sets the protocol method to use in this request.
Definition: WebRequest.cs:202
virtual Task< WebResponse > GetResponseAsync()
When overridden in a descendant class, returns a response to an Internet request as an asynchronous o...
Definition: WebRequest.cs:813
virtual bool PreAuthenticate
When overridden in a descendant class, indicates whether to pre-authenticate the request.
Definition: WebRequest.cs:355
static int CompareExchange(ref int location1, int value, int comparand)
Compares two 32-bit signed integers for equality and, if they are equal, replaces the first value.
static bool RegisterPrefix(string prefix, IWebRequestCreate creator)
Registers a T:System.Net.WebRequest descendant for the specified URI.
Definition: WebRequest.cs:624
static IWebProxy GetSystemWebProxy()
Returns a proxy configured with the Internet Explorer settings of the currently impersonated user.
Definition: WebRequest.cs:881
virtual Delegate CreateDelegate(Type delegateType)
Creates a delegate of the specified type from this method.
Definition: MethodInfo.cs:143
Uri GetProxy(Uri destination)
Returns the proxied URI for a request.
Definition: WebProxy.cs:294
Provides the base authentication interface for retrieving credentials for Web client authentication.
Definition: ICredentials.cs:5
static RequestCachePolicy DefaultCachePolicy
Gets or sets the default cache policy for this request.
Definition: WebRequest.cs:170
string OriginalString
Gets the original URI string that was passed to the T:System.Uri constructor.
Definition: Uri.cs:739
static HttpWebRequest CreateHttp(Uri requestUri)
Initializes a new T:System.Net.HttpWebRequest instance for the specified URI.
Definition: WebRequest.cs:602
WebRequest()
Initializes a new instance of the T:System.Net.WebRequest class.
Definition: WebRequest.cs:673
virtual long ContentLength
When overridden in a descendant class, gets or sets the content length of the request data being sent...
Definition: WebRequest.cs:265
Defines an application's caching requirements for resources obtained by using T:System....
Contains constants that specify infinite time-out intervals. This class cannot be inherited.
Definition: Timeout.cs:8
Stores all the data needed to serialize or deserialize an object. This class cannot be inherited.
virtual ICredentials Credentials
When overridden in a descendant class, gets or sets the network credentials used for authenticating t...
Definition: WebRequest.cs:299
static void RegisterPortableWebRequestCreator(IWebRequestCreate creator)
Register an T:System.Net.IWebRequestCreate object.
Definition: WebRequest.cs:482
virtual void Abort()
Aborts the Request
Definition: WebRequest.cs:854
UriFormat
Controls how URI information is escaped.
Definition: UriFormat.cs:5
Allows an object to control its own serialization and deserialization.
Definition: ISerializable.cs:8
static bool IsFlowSuppressed()
Indicates whether the flow of the execution context is currently suppressed.
virtual IAsyncResult BeginGetResponse(AsyncCallback callback, object state)
When overridden in a descendant class, begins an asynchronous request for an Internet resource.
Definition: WebRequest.cs:737
virtual bool UseDefaultCredentials
When overridden in a descendant class, gets or sets a T:System.Boolean value that controls whether P:...
Definition: WebRequest.cs:319
Task< TResult > FromAsync(IAsyncResult asyncResult, Func< IAsyncResult, TResult > endMethod)
Creates a task that executes an end method function when a specified T:System.IAsyncResult completes.
Definition: TaskFactory.cs:403
virtual void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext)
Populates a T:System.Runtime.Serialization.SerializationInfo with the data needed to serialize the ta...
Definition: WebRequest.cs:701
static HttpWebRequest CreateHttp(string requestUriString)
Initializes a new T:System.Net.HttpWebRequest instance for the specified URI string.
Definition: WebRequest.cs:584
bool IsBypassed(Uri host)
Indicates whether to use the proxy server for the specified host.
Definition: WebProxy.cs:418
virtual WebHeaderCollection Headers
When overridden in a descendant class, gets or sets the collection of header name/value pairs associa...
Definition: WebRequest.cs:248
Specifies that the class can be serialized.
virtual IWebProxy Proxy
When overridden in a descendant class, gets or sets the network proxy to use to access this Internet ...
Definition: WebRequest.cs:337
static Task Run(Action action)
Queues the specified work to run on the thread pool and returns a T:System.Threading....
Definition: Task.cs:4209
RequestCacheLevel
Specifies caching behavior for resources obtained using T:System.Net.WebRequest and its derived class...
ICredentials Credentials
The credentials to submit to the proxy server for authentication.
Definition: IWebProxy.cs:11
Provides the base interface for implementation of proxy access for the T:System.Net....
Definition: IWebProxy.cs:5
virtual WebResponse GetResponse()
When overridden in a descendant class, returns a response to an Internet request.
Definition: WebRequest.cs:725
The exception that is thrown when an invoked method is not supported, or when there is an attempt to ...
SecurityPermissionFlag
Specifies access flags for the security permission object.
Provides support for creating and scheduling T:System.Threading.Tasks.Task`1 objects.
Definition: TaskFactory.cs:12
Provides an object representation of a uniform resource identifier (URI) and easy access to the parts...
Definition: Uri.cs:19
static readonly string UriSchemeHttps
Specifies that the URI is accessed through the Secure Hypertext Transfer Protocol (HTTPS)....
Definition: Uri.cs:157
Provides an HTTP-specific implementation of the T:System.Net.WebRequest class.
static IWebProxy DefaultWebProxy
Gets or sets the global HTTP proxy.
Definition: WebRequest.cs:463
virtual Uri RequestUri
When overridden in a descendant class, gets the URI of the Internet resource associated with the requ...
Definition: WebRequest.cs:220
virtual WebResponse EndGetResponse(IAsyncResult asyncResult)
When overridden in a descendant class, returns a T:System.Net.WebResponse.
Definition: WebRequest.cs:747
void GetObjectData(SerializationInfo info, StreamingContext context)
Populates a T:System.Runtime.Serialization.SerializationInfo with the data needed to serialize the ta...
Provides atomic operations for variables that are shared by multiple threads.
Definition: Interlocked.cs:10
override string ToString()
Gets a canonical string representation for the specified T:System.Uri instance.
Definition: Uri.cs:1663
The exception that is thrown when a requested method or operation is not implemented.
WebRequest(SerializationInfo serializationInfo, StreamingContext streamingContext)
Initializes a new instance of the T:System.Net.WebRequest class from the specified instances of the T...
Definition: WebRequest.cs:683
Contains HTTP proxy settings for the T:System.Net.WebRequest class.
Definition: WebProxy.cs:13
Represents an asynchronous operation that can return a value.
Definition: Task.cs:18
AuthenticationLevel
Specifies client requirements for authentication and impersonation when using the T:System....
Implements the T:System.Collections.IList interface using an array whose size is dynamically increase...
Definition: ArrayList.cs:14
Provides a generic view of a sequence of bytes. This is an abstract class.To browse the ....
Definition: Stream.cs:16
Enables access to objects across application domain boundaries in applications that support remoting.