20 [global::__DynamicallyInvokable]
31 internal class WebProxyWrapperOpaque : IAutoWebProxy,
IWebProxy 33 protected readonly
WebProxy webProxy;
39 return webProxy.Credentials;
43 webProxy.Credentials = value;
47 internal WebProxyWrapperOpaque(
WebProxy webProxy)
49 this.webProxy = webProxy;
52 public Uri GetProxy(
Uri destination)
54 return webProxy.
GetProxy(destination);
57 public bool IsBypassed(
Uri host)
62 public ProxyChain GetProxies(
Uri destination)
64 return ((IAutoWebProxy)webProxy).GetProxies(destination);
68 internal class WebProxyWrapper : WebProxyWrapperOpaque
72 internal WebProxyWrapper(
WebProxy webProxy)
78 private delegate
void DelEtwFireBeginWRGet(
object id,
string uri,
bool success,
bool synchronous);
80 private delegate
void DelEtwFireEndWRGet(
object id,
bool success,
bool synchronous);
82 private delegate
void DelEtwFireEndWRespGet(
object id,
bool success,
bool synchronous,
int statusCode);
84 internal const int DefaultTimeout = 100000;
86 private static volatile ArrayList s_PrefixList;
88 private static object s_InternalSyncObject;
90 private static TimerThread.Queue s_DefaultTimerQueue = TimerThread.CreateQueue(100000);
98 private RequestCacheProtocol m_CacheProtocol;
100 private RequestCacheBinding m_CacheBinding;
102 private static DesignerWebRequestCreate webRequestCreate =
new DesignerWebRequestCreate();
104 private static volatile IWebProxy s_DefaultWebProxy;
106 private static volatile bool s_DefaultWebProxyInitialized;
108 private static DelEtwFireBeginWRGet s_EtwFireBeginGetResponse;
110 private static DelEtwFireEndWRespGet s_EtwFireEndGetResponse;
112 private static DelEtwFireBeginWRGet s_EtwFireBeginGetRequestStream;
114 private static DelEtwFireEndWRGet s_EtwFireEndGetRequestStream;
116 private static volatile bool s_TriedGetEtwDelegates;
120 [Obsolete(
"This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.",
true)]
126 return webRequestCreate;
130 private static object InternalSyncObject
134 if (s_InternalSyncObject ==
null)
136 object value =
new object();
139 return s_InternalSyncObject;
143 internal static TimerThread.Queue DefaultTimerQueue => s_DefaultTimerQueue;
149 if (s_PrefixList ==
null)
151 lock (InternalSyncObject)
153 if (s_PrefixList ==
null)
155 s_PrefixList = WebRequestModulesSectionInternal.GetSection().WebRequestModules;
163 s_PrefixList = value;
173 return RequestCacheManager.GetBinding(
string.Empty).Policy;
177 ExceptionHelper.WebPermissionUnrestricted.Demand();
178 RequestCacheBinding binding = RequestCacheManager.GetBinding(
string.Empty);
179 RequestCacheManager.SetBinding(
string.Empty,
new RequestCacheBinding(binding.Cache, binding.Validator, value));
189 return m_CachePolicy;
193 InternalSetCachePolicy(value);
200 [global::__DynamicallyInvokable]
201 public virtual string Method 203 [global::__DynamicallyInvokable]
206 throw ExceptionHelper.PropertyNotImplementedException;
208 [global::__DynamicallyInvokable]
211 throw ExceptionHelper.PropertyNotImplementedException;
218 [global::__DynamicallyInvokable]
221 [global::__DynamicallyInvokable]
224 throw ExceptionHelper.PropertyNotImplementedException;
235 throw ExceptionHelper.PropertyNotImplementedException;
239 throw ExceptionHelper.PropertyNotImplementedException;
246 [global::__DynamicallyInvokable]
249 [global::__DynamicallyInvokable]
252 throw ExceptionHelper.PropertyNotImplementedException;
254 [global::__DynamicallyInvokable]
257 throw ExceptionHelper.PropertyNotImplementedException;
268 throw ExceptionHelper.PropertyNotImplementedException;
272 throw ExceptionHelper.PropertyNotImplementedException;
279 [global::__DynamicallyInvokable]
282 [global::__DynamicallyInvokable]
285 throw ExceptionHelper.PropertyNotImplementedException;
287 [global::__DynamicallyInvokable]
290 throw ExceptionHelper.PropertyNotImplementedException;
297 [global::__DynamicallyInvokable]
300 [global::__DynamicallyInvokable]
303 throw ExceptionHelper.PropertyNotImplementedException;
305 [global::__DynamicallyInvokable]
308 throw ExceptionHelper.PropertyNotImplementedException;
317 [global::__DynamicallyInvokable]
320 [global::__DynamicallyInvokable]
323 throw ExceptionHelper.PropertyNotImplementedException;
325 [global::__DynamicallyInvokable]
328 throw ExceptionHelper.PropertyNotImplementedException;
335 [global::__DynamicallyInvokable]
338 [global::__DynamicallyInvokable]
341 throw ExceptionHelper.PropertyNotImplementedException;
343 [global::__DynamicallyInvokable]
346 throw ExceptionHelper.PropertyNotImplementedException;
358 throw ExceptionHelper.PropertyNotImplementedException;
362 throw ExceptionHelper.PropertyNotImplementedException;
373 throw ExceptionHelper.PropertyNotImplementedException;
377 throw ExceptionHelper.PropertyNotImplementedException;
381 internal RequestCacheProtocol CacheProtocol
385 return m_CacheProtocol;
389 m_CacheProtocol = value;
399 return m_AuthenticationLevel;
403 m_AuthenticationLevel = value;
413 return m_ImpersonationLevel;
417 m_ImpersonationLevel = value;
421 internal static IWebProxy InternalDefaultWebProxy
425 if (!s_DefaultWebProxyInitialized)
427 lock (InternalSyncObject)
429 if (!s_DefaultWebProxyInitialized)
431 DefaultProxySectionInternal section = DefaultProxySectionInternal.GetSection();
434 s_DefaultWebProxy = section.WebProxy;
436 s_DefaultWebProxyInitialized =
true;
440 return s_DefaultWebProxy;
444 if (!s_DefaultWebProxyInitialized)
446 lock (InternalSyncObject)
448 s_DefaultWebProxy = value;
449 s_DefaultWebProxyInitialized =
true;
454 s_DefaultWebProxy = value;
461 [global::__DynamicallyInvokable]
464 [global::__DynamicallyInvokable]
467 ExceptionHelper.WebPermissionUnrestricted.Demand();
468 return InternalDefaultWebProxy;
470 [global::__DynamicallyInvokable]
473 ExceptionHelper.WebPermissionUnrestricted.Demand();
474 InternalDefaultWebProxy = value;
480 [Obsolete(
"This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.",
true)]
486 private static WebRequest Create(
Uri requestUri,
bool useUriBase)
490 Logging.Enter(Logging.Web,
"WebRequest",
"Create", requestUri.
ToString());
492 WebRequestPrefixElement webRequestPrefixElement =
null;
495 int length = text.Length;
497 for (
int i = 0; i < prefixList.Count; i++)
499 webRequestPrefixElement = (WebRequestPrefixElement)prefixList[i];
500 if (length >= webRequestPrefixElement.Prefix.Length &&
string.Compare(webRequestPrefixElement.Prefix, 0, text, 0, webRequestPrefixElement.Prefix.Length,
StringComparison.OrdinalIgnoreCase) == 0)
509 webRequest = webRequestPrefixElement.Creator.Create(requestUri);
512 Logging.Exit(Logging.Web,
"WebRequest",
"Create", webRequest);
518 Logging.Exit(Logging.Web,
"WebRequest",
"Create",
null);
520 throw new NotSupportedException(SR.GetString(
"net_unknown_prefix"));
532 [global::__DynamicallyInvokable]
535 if (requestUriString ==
null)
539 return Create(
new Uri(requestUriString), useUriBase:
false);
549 [global::__DynamicallyInvokable]
552 if (requestUri ==
null)
556 return Create(requestUri, useUriBase:
false);
568 if (requestUri ==
null)
572 return Create(requestUri, useUriBase:
true);
583 [global::__DynamicallyInvokable]
586 if (requestUriString ==
null)
601 [global::__DynamicallyInvokable]
604 if (requestUri ==
null)
623 [global::__DynamicallyInvokable]
635 ExceptionHelper.WebPermissionUnrestricted.Demand();
636 lock (InternalSyncObject)
641 string text = result.AbsoluteUri;
644 text = text.Substring(0, text.Length - 1);
649 for (i = 0; i < arrayList.
Count; i++)
651 WebRequestPrefixElement webRequestPrefixElement = (WebRequestPrefixElement)arrayList[i];
652 if (prefix.Length > webRequestPrefixElement.Prefix.Length)
656 if (prefix.Length == webRequestPrefixElement.Prefix.Length &&
string.Compare(webRequestPrefixElement.Prefix, prefix,
StringComparison.OrdinalIgnoreCase) == 0)
664 arrayList.
Insert(i,
new WebRequestPrefixElement(prefix, creator));
665 PrefixList = arrayList;
672 [global::__DynamicallyInvokable]
694 GetObjectData(serializationInfo, streamingContext);
707 if (m_CacheBinding !=
null && m_CacheBinding.Cache !=
null && m_CacheBinding.Validator !=
null && CacheProtocol ==
null && policy !=
null && policy.
Level !=
RequestCacheLevel.BypassCache)
709 CacheProtocol =
new RequestCacheProtocol(m_CacheBinding.Cache, m_CacheBinding.Validator.CreateValidator());
711 m_CachePolicy = policy;
719 throw ExceptionHelper.MethodNotImplementedException;
727 throw ExceptionHelper.MethodNotImplementedException;
735 [global::__DynamicallyInvokable]
736 [HostProtection(
SecurityAction.LinkDemand, ExternalThreading =
true)]
739 throw ExceptionHelper.MethodNotImplementedException;
746 [global::__DynamicallyInvokable]
749 throw ExceptionHelper.MethodNotImplementedException;
757 [global::__DynamicallyInvokable]
758 [HostProtection(
SecurityAction.LinkDemand, ExternalThreading =
true)]
761 throw ExceptionHelper.MethodNotImplementedException;
768 [global::__DynamicallyInvokable]
771 throw ExceptionHelper.MethodNotImplementedException;
776 [global::__DynamicallyInvokable]
777 [HostProtection(
SecurityAction.LinkDemand, ExternalThreading =
true)]
811 [global::__DynamicallyInvokable]
812 [HostProtection(
SecurityAction.LinkDemand, ExternalThreading =
true)]
834 Func<AsyncCallback, object, IAsyncResult> beginMethod = webRequest.
BeginGetResponse;
844 [SecuritySafeCritical]
853 [global::__DynamicallyInvokable]
856 throw ExceptionHelper.MethodNotImplementedException;
859 internal virtual ContextAwareResult GetConnectingContext()
861 throw ExceptionHelper.MethodNotImplementedException;
864 internal virtual ContextAwareResult GetWritingContext()
866 throw ExceptionHelper.MethodNotImplementedException;
869 internal virtual ContextAwareResult GetReadingContext()
871 throw ExceptionHelper.MethodNotImplementedException;
874 internal virtual void RequestCallback(
object obj)
876 throw ExceptionHelper.MethodNotImplementedException;
883 ExceptionHelper.WebPermissionUnrestricted.Demand();
884 return InternalGetSystemWebProxy();
887 internal static IWebProxy InternalGetSystemWebProxy()
889 return new WebProxyWrapperOpaque(
new WebProxy(enableAutoproxy:
true));
892 internal void SetupCacheProtocol(
Uri uri)
894 m_CacheBinding = RequestCacheManager.GetBinding(uri.
Scheme);
895 InternalSetCachePolicy(m_CacheBinding.Policy);
896 if (m_CachePolicy ==
null)
902 private static void InitEtwMethods()
904 Type typeFromHandle = typeof(FrameworkEventSource);
913 MethodInfo method = typeFromHandle.GetMethod(
"BeginGetResponse", bindingAttr,
null, types,
null);
914 MethodInfo method2 = typeFromHandle.GetMethod(
"EndGetResponse", bindingAttr,
null,
new Type[4]
921 MethodInfo method3 = typeFromHandle.GetMethod(
"BeginGetRequestStream", bindingAttr,
null, types,
null);
922 MethodInfo method4 = typeFromHandle.GetMethod(
"EndGetRequestStream", bindingAttr,
null,
new Type[3]
928 if (method !=
null && method2 !=
null && method3 !=
null && method4 !=
null)
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);
935 s_TriedGetEtwDelegates =
true;
938 internal void LogBeginGetResponse(
bool success,
bool synchronous)
941 if (!s_TriedGetEtwDelegates)
945 if (s_EtwFireBeginGetResponse !=
null)
947 s_EtwFireBeginGetResponse(
this, originalString, success, synchronous);
951 internal void LogEndGetResponse(
bool success,
bool synchronous,
int statusCode)
953 if (!s_TriedGetEtwDelegates)
957 if (s_EtwFireEndGetResponse !=
null)
959 s_EtwFireEndGetResponse(
this, success, synchronous, statusCode);
963 internal void LogBeginGetRequestStream(
bool success,
bool synchronous)
966 if (!s_TriedGetEtwDelegates)
970 if (s_EtwFireBeginGetRequestStream !=
null)
972 s_EtwFireBeginGetRequestStream(
this, originalString, success, synchronous);
976 internal void LogEndGetRequestStream(
bool success,
bool synchronous)
978 if (!s_TriedGetEtwDelegates)
982 if (s_EtwFireEndGetRequestStream !=
null)
984 s_EtwFireEndGetRequestStream(
this, success, synchronous);
UriKind
Defines the kinds of T:System.Uris for the M:System.Uri.IsWellFormedUriString(System....
TokenImpersonationLevel ImpersonationLevel
Gets or sets the impersonation level for the current request.
static new TaskFactory< TResult > Factory
Provides access to factory methods for creating and configuring T:System.Threading....
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)....
virtual Stream EndGetRequestStream(IAsyncResult asyncResult)
When overridden in a descendant class, returns a T:System.IO.Stream for writing data to the Internet ...
virtual IAsyncResult BeginGetRequestStream(AsyncCallback callback, object state)
When overridden in a descendant class, provides an asynchronous version of the M:System....
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.
Discovers the attributes of a method and provides access to method metadata.
virtual string ConnectionGroupName
When overridden in a descendant class, gets or sets the name of the connection group for the request.
static WebRequest Create(string requestUriString)
Initializes a new T:System.Net.WebRequest instance for the specified URI scheme.
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.
string AbsoluteUri
Gets the absolute URI.
virtual Task< Stream > GetRequestStreamAsync()
When overridden in a descendant class, returns a T:System.IO.Stream for writing data to the Internet ...
Makes a request to a Uniform Resource Identifier (URI). This is an abstract class.
virtual int Count
Gets the number of elements actually contained in the T:System.Collections.ArrayList.
BindingFlags
Specifies flags that control binding and the way in which the search for members and types is conduct...
string Scheme
Gets the scheme name for this URI.
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.
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....
virtual IWebRequestCreate CreatorInstance
When overridden in a descendant class, gets the factory object derived from the T:System....
UriComponents
Specifies the parts of a T:System.Uri.
static WebRequest Create(Uri requestUri)
Initializes a new T:System.Net.WebRequest instance for the specified URI scheme.
Represents a Windows user.
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.
Provides a response from a Uniform Resource Identifier (URI). This is an abstract class.
Represents the status of an asynchronous operation.
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.
virtual Stream GetRequestStream()
When overridden in a descendant class, returns a T:System.IO.Stream for writing data to the Internet ...
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.
virtual Task< WebResponse > GetResponseAsync()
When overridden in a descendant class, returns a response to an Internet request as an asynchronous o...
virtual bool PreAuthenticate
When overridden in a descendant class, indicates whether to pre-authenticate the request.
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.
static IWebProxy GetSystemWebProxy()
Returns a proxy configured with the Internet Explorer settings of the currently impersonated user.
virtual Delegate CreateDelegate(Type delegateType)
Creates a delegate of the specified type from this method.
Uri GetProxy(Uri destination)
Returns the proxied URI for a request.
Provides the base authentication interface for retrieving credentials for Web client authentication.
static RequestCachePolicy DefaultCachePolicy
Gets or sets the default cache policy for this request.
string OriginalString
Gets the original URI string that was passed to the T:System.Uri constructor.
static HttpWebRequest CreateHttp(Uri requestUri)
Initializes a new T:System.Net.HttpWebRequest instance for the specified URI.
WebRequest()
Initializes a new instance of the T:System.Net.WebRequest class.
virtual long ContentLength
When overridden in a descendant class, gets or sets the content length of the request data being sent...
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.
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...
static void RegisterPortableWebRequestCreator(IWebRequestCreate creator)
Register an T:System.Net.IWebRequestCreate object.
virtual void Abort()
Aborts the Request
UriFormat
Controls how URI information is escaped.
Allows an object to control its own serialization and deserialization.
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.
virtual bool UseDefaultCredentials
When overridden in a descendant class, gets or sets a T:System.Boolean value that controls whether P:...
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.
virtual void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext)
Populates a T:System.Runtime.Serialization.SerializationInfo with the data needed to serialize the ta...
static HttpWebRequest CreateHttp(string requestUriString)
Initializes a new T:System.Net.HttpWebRequest instance for the specified URI string.
bool IsBypassed(Uri host)
Indicates whether to use the proxy server for the specified host.
virtual WebHeaderCollection Headers
When overridden in a descendant class, gets or sets the collection of header name/value pairs associa...
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 ...
static Task Run(Action action)
Queues the specified work to run on the thread pool and returns a T:System.Threading....
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.
Provides the base interface for implementation of proxy access for the T:System.Net....
virtual WebResponse GetResponse()
When overridden in a descendant class, returns a response to an Internet request.
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.
Provides an object representation of a uniform resource identifier (URI) and easy access to the parts...
static readonly string UriSchemeHttps
Specifies that the URI is accessed through the Secure Hypertext Transfer Protocol (HTTPS)....
Provides an HTTP-specific implementation of the T:System.Net.WebRequest class.
static IWebProxy DefaultWebProxy
Gets or sets the global HTTP proxy.
virtual Uri RequestUri
When overridden in a descendant class, gets the URI of the Internet resource associated with the requ...
virtual WebResponse EndGetResponse(IAsyncResult asyncResult)
When overridden in a descendant class, returns a T:System.Net.WebResponse.
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.
override string ToString()
Gets a canonical string representation for the specified T:System.Uri instance.
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...
Contains HTTP proxy settings for the T:System.Net.WebRequest class.
Represents an asynchronous operation that can return a value.
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...
Provides a generic view of a sequence of bytes. This is an abstract class.To browse the ....
Enables access to objects across application domain boundaries in applications that support remoting.