using System.Net.Configuration;
using System.Net.Security;
using System.Net.Cache;
+using System.Security.Principal;
#endif
namespace System.Net
public abstract class WebRequest : MarshalByRefObject, ISerializable
{
static HybridDictionary prefixes = new HybridDictionary ();
+#if NET_2_0
+ static bool isDefaultWebProxySet;
+ static IWebProxy defaultWebProxy;
+#endif
// Constructors
protected WebRequest (SerializationInfo serializationInfo, StreamingContext streamingContext)
{
+#if ONLY_1_1
+ throw GetMustImplement ();
+#endif
}
static Exception GetMustImplement ()
throw GetMustImplement ();
}
set {
- throw GetMustImplement ();
}
}
#endif
- public virtual string ConnectionGroupName {
+ public virtual string ConnectionGroupName {
get { throw GetMustImplement (); }
set { throw GetMustImplement (); }
}
set { throw GetMustImplement (); }
}
+#if NET_2_0
+ public TokenImpersonationLevel ImpersonationLevel {
+ get { throw GetMustImplement (); }
+ set { throw GetMustImplement (); }
+ }
+#endif
public virtual string Method {
get { throw GetMustImplement (); }
set { throw GetMustImplement (); }
}
}
- volatile static IWebProxy proxy;
+// volatile static IWebProxy proxy;
static readonly object lockobj = new object ();
public static IWebProxy DefaultWebProxy {
get {
- lock (lockobj) {
- if (proxy == null)
- proxy = GetDefaultWebProxy ();
- return proxy;
+ if (!isDefaultWebProxySet) {
+ lock (lockobj) {
+ if (defaultWebProxy == null)
+ defaultWebProxy = GetDefaultWebProxy ();
+ }
}
+ return defaultWebProxy;
}
set {
- if (value == null)
- throw new ArgumentNullException ("WebRequest.DefaultWebProxy",
- "null IWebProxy not allowed.");
- proxy = value;
+ /* MS documentation states that a null value would cause an ArgumentNullException
+ * but that's not the way it behaves:
+ * https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=304724
+ */
+ defaultWebProxy = value;
+ isDefaultWebProxySet = true;
}
}
p.BypassProxyOnLocal = (pe.BypassOnLocal == ProxyElement.BypassOnLocalValues.True);
#endif
return p;
- }
+ }
#endif
// Methods
return new WebProxy ();
}
#endif
-#if TARGET_JVM
- public virtual void GetObjectData
-#else
+
void ISerializable.GetObjectData
-#endif
(SerializationInfo serializationInfo,
StreamingContext streamingContext)
{
throw new NotSupportedException ();
}
+
#if NET_2_0
protected virtual void GetObjectData (SerializationInfo serializationInfo, StreamingContext streamingContext)
{
public static bool RegisterPrefix (string prefix, IWebRequestCreate creator)
{
if (prefix == null)
- throw new ArgumentNullException("prefix");
+ throw new ArgumentNullException ("prefix");
if (creator == null)
- throw new ArgumentNullException("creator");
+ throw new ArgumentNullException ("creator");
lock (prefixes.SyncRoot) {
string lowerCasePrefix = prefix.ToLower (CultureInfo.InvariantCulture);
continue;
if (!prefix.StartsWith (key))
- continue;
+ continue;
longestPrefix = key.Length;
creator = (IWebRequestCreate) e.Value;