namespace System.Net
{
-#if MOONLIGHT
- internal abstract class WebRequest : ISerializable {
-#else
[Serializable]
public abstract class WebRequest : MarshalByRefObject, ISerializable {
-#endif
static HybridDictionary prefixes = new HybridDictionary ();
static bool isDefaultWebProxySet;
static IWebProxy defaultWebProxy;
static RequestCachePolicy defaultCachePolicy;
-
- // Constructors
-
+
static WebRequest ()
{
-#if NET_2_1
+#if MOBILE
IWebRequestCreate http = new HttpRequestCreator ();
RegisterPrefix ("http", http);
RegisterPrefix ("https", http);
- #if MOBILE
RegisterPrefix ("file", new FileWebRequestCreator ());
RegisterPrefix ("ftp", new FtpRequestCreator ());
- #endif
#else
- defaultCachePolicy = new HttpRequestCachePolicy (HttpRequestCacheLevel.NoCacheNoStore);
#if CONFIGURATION_DEP
object cfg = ConfigurationManager.GetSection ("system.net/webRequestModules");
WebRequestModulesSection s = cfg as WebRequestModulesSection;
authentication_level = value;
}
}
-
- [MonoTODO ("Implement the caching system. Currently always returns a policy with the NoCacheNoStore level")]
- public virtual RequestCachePolicy CachePolicy
- {
- get { return DefaultCachePolicy; }
- set {
- }
- }
public virtual string ConnectionGroupName {
get { throw GetMustImplement (); }
set { throw GetMustImplement (); }
}
- public static RequestCachePolicy DefaultCachePolicy
+ [MonoTODO ("Implement the caching system. Currently always returns a policy with the NoCacheNoStore level")]
+ public virtual RequestCachePolicy CachePolicy
{
- get { return defaultCachePolicy; }
+ get { return DefaultCachePolicy; }
+ set {
+ }
+ }
+
+ public static RequestCachePolicy DefaultCachePolicy {
+ get {
+ return defaultCachePolicy ?? (defaultCachePolicy = new HttpRequestCachePolicy (HttpRequestCacheLevel.NoCacheNoStore));
+ }
set {
throw GetMustImplement ();
}
set { throw GetMustImplement (); }
}
-#if !MOONLIGHT
- public TokenImpersonationLevel ImpersonationLevel {
- get { throw GetMustImplement (); }
- set { throw GetMustImplement (); }
- }
-#endif
+
public virtual string Method {
get { throw GetMustImplement (); }
set { throw GetMustImplement (); }
throw GetMustImplement ();
}
}
-
+
+ public TokenImpersonationLevel ImpersonationLevel { get; set; }
+
// volatile static IWebProxy proxy;
static readonly object lockobj = new object ();
throw new ArgumentNullException ("requestUri");
return GetCreator (requestUri.Scheme).Create (requestUri);
}
-#if NET_4_5 || MOBILE
+#if NET_4_0
[MonoTODO ("for portable library support")]
public static HttpWebRequest CreateHttp (string requestUriString)
{
[MonoTODO("Look in other places for proxy config info")]
public static IWebProxy GetSystemWebProxy ()
{
+#if MONOTOUCH
+ return CFNetwork.GetDefaultProxy ();
+#else
+#if MONODROID
+ // Return the system web proxy. This only works for ICS+.
+ var androidProxy = AndroidPlatform.GetDefaultProxy ();
+ if (androidProxy != null)
+ return androidProxy;
+#endif
#if !NET_2_1
if (IsWindows ()) {
int iProxyEnable = (int)Microsoft.Win32.Registry.GetValue ("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", "ProxyEnable", 0);
#endif
return new WebProxy ();
+#endif // MONOTOUCH
}
void ISerializable.GetObjectData (SerializationInfo serializationInfo, StreamingContext streamingContext)