diff --git a/mcs/class/System/System.Net/AuthenticationManager.cs b/mcs/class/System/System.Net/AuthenticationManager.cs index e364fc8cb5284..6d96df0b1ae1e 100755 --- a/mcs/class/System/System.Net/AuthenticationManager.cs +++ b/mcs/class/System/System.Net/AuthenticationManager.cs @@ -17,6 +17,10 @@ public class AuthenticationManager { static ArrayList modules; + private AuthenticationManager () + { + } + static void EnsureModules () { if (modules != null) diff --git a/mcs/class/System/System.Net/ChangeLog b/mcs/class/System/System.Net/ChangeLog index 38ce65891a674..a1066a3ff39aa 100644 --- a/mcs/class/System/System.Net/ChangeLog +++ b/mcs/class/System/System.Net/ChangeLog @@ -1,14 +1,29 @@ +2003-06-26 Gonzalo Paniagua Javier + + * WebConnection.cs: close the socket and connection when disposing. + * WebRequest.cs: removed setter for RequestUri. Allow non-public ctors + when creating instances. + + * HttpWebRequest.cs: + * HttpWebResponse.cs: + * FileWebRequest.cs: support serialization. + + * FileWebResponse.cs: support serialization and fixed dispose checks. + + * FileWebRequestCreator.cs: + * HttpRequestCreator.cs: added internal .ctor. + 2003-06-24 Lluis Sanchez Gual - * HttpWebRequest.cs: SetWriteStream(): SendRequestHeaders should be called - before asyncWrite.SetCompleted, to make sure that the waiting thread - does not start to send more information before SendRequestHeaders has - finished. + * HttpWebRequest.cs: SetWriteStream(): SendRequestHeaders should be + called before asyncWrite.SetCompleted, to make sure that the waiting + thread does not start to send more information before + SendRequestHeaders has finished. 2003-06-22 Lluis Sanchez Gual - * WebConnectionStream.cs: Only increment pendingReads if an asynchronous read - is really needed. + * WebConnectionStream.cs: Only increment pendingReads if an asynchronous + read is really needed. 2003-06-20 Gonzalo Paniagua Javier diff --git a/mcs/class/System/System.Net/ConnectionModes.cs b/mcs/class/System/System.Net/ConnectionModes.cs index 3a1cc43770232..7ce122223bc42 100755 --- a/mcs/class/System/System.Net/ConnectionModes.cs +++ b/mcs/class/System/System.Net/ConnectionModes.cs @@ -15,7 +15,7 @@ namespace System.Net { /// /// - public enum ConnectionModes { + enum ConnectionModes { /// /// diff --git a/mcs/class/System/System.Net/FileWebRequest.cs b/mcs/class/System/System.Net/FileWebRequest.cs index 899c10f7676cf..84234017670b4 100644 --- a/mcs/class/System/System.Net/FileWebRequest.cs +++ b/mcs/class/System/System.Net/FileWebRequest.cs @@ -22,14 +22,14 @@ public class FileWebRequest : WebRequest, ISerializable private ICredentials credentials; private string connectionGroup; - private string method; - private int timeout; + private string method = "GET"; + private int timeout = 100000; - private Stream requestStream = null; - private FileWebResponse webResponse = null; - private AutoResetEvent requestEndEvent = null; - private bool requesting = false; - private bool asyncResponding = false; + private Stream requestStream; + private FileWebResponse webResponse; + private AutoResetEvent requestEndEvent; + private bool requesting; + private bool asyncResponding; // Constructors @@ -37,14 +37,17 @@ internal FileWebRequest (Uri uri) { this.uri = uri; this.webHeaders = new WebHeaderCollection (); - this.method = "GET"; - this.timeout = System.Threading.Timeout.Infinite; } - [MonoTODO] protected FileWebRequest (SerializationInfo serializationInfo, StreamingContext streamingContext) { - throw new NotImplementedException (); + SerializationInfo info = serializationInfo; + + method = info.GetString ("method"); + uri = (Uri) info.GetValue ("uri", typeof (Uri)); + timeout = info.GetInt32 ("timeout"); + connectionGroup = info.GetString ("connectionGroup"); + webHeaders = (WebHeaderCollection) info.GetValue ("webHeaders", typeof (WebHeaderCollection)); } // Properties @@ -224,7 +227,7 @@ public override WebResponse GetResponse () return EndGetResponse (asyncResult); } - public WebResponse GetResponseInternal () + WebResponse GetResponseInternal () { if (webResponse != null) return webResponse; @@ -245,11 +248,15 @@ public WebResponse GetResponseInternal () return (WebResponse) this.webResponse; } - [MonoTODO] - void ISerializable.GetObjectData (SerializationInfo serializationInfo, - StreamingContext streamingContext) + void ISerializable.GetObjectData (SerializationInfo serializationInfo, StreamingContext streamingContext) { - throw new NotImplementedException (); + SerializationInfo info = serializationInfo; + + info.AddValue ("method", method); + info.AddValue ("uri", uri, typeof (Uri)); + info.AddValue ("timeout", timeout); + info.AddValue ("connectionGroup", connectionGroup); + info.AddValue ("webHeaders", webHeaders, typeof (WebHeaderCollection)); } internal void Close () @@ -292,4 +299,4 @@ public override void Close() } } } -} \ No newline at end of file +} diff --git a/mcs/class/System/System.Net/FileWebRequestCreator.cs b/mcs/class/System/System.Net/FileWebRequestCreator.cs index c20ab9ca5bb74..2e4d973b99844 100644 --- a/mcs/class/System/System.Net/FileWebRequestCreator.cs +++ b/mcs/class/System/System.Net/FileWebRequestCreator.cs @@ -11,6 +11,10 @@ namespace System.Net { class FileWebRequestCreator : IWebRequestCreate { + internal FileWebRequestCreator () + { + } + public WebRequest Create (Uri uri) { return new FileWebRequest (uri); diff --git a/mcs/class/System/System.Net/FileWebResponse.cs b/mcs/class/System/System.Net/FileWebResponse.cs index d4acb6e79e9b9..c50928245719a 100644 --- a/mcs/class/System/System.Net/FileWebResponse.cs +++ b/mcs/class/System/System.Net/FileWebResponse.cs @@ -22,8 +22,6 @@ public class FileWebResponse : WebResponse, ISerializable, IDisposable // Constructors - protected FileWebResponse () { } - internal FileWebResponse (Uri responseUri, FileStream fileStream) { try { @@ -38,57 +36,60 @@ internal FileWebResponse (Uri responseUri, FileStream fileStream) } } - [MonoTODO] protected FileWebResponse (SerializationInfo serializationInfo, StreamingContext streamingContext) { - throw new NotImplementedException (); + SerializationInfo info = serializationInfo; + + responseUri = (Uri) info.GetValue ("responseUri", typeof (Uri)); + contentLength = info.GetInt64 ("contentLength"); + webHeaders = (WebHeaderCollection) info.GetValue ("webHeaders", typeof (WebHeaderCollection)); } // Properties public override long ContentLength { get { - try { return this.contentLength; } - finally { CheckDisposed (); } + CheckDisposed (); + return this.contentLength; } } public override string ContentType { get { - try { return "binary/octet-stream"; } - finally { CheckDisposed (); } + CheckDisposed (); + return "binary/octet-stream"; } } public override WebHeaderCollection Headers { get { - try { return this.webHeaders; } - finally { CheckDisposed (); } + CheckDisposed (); + return this.webHeaders; } } public override Uri ResponseUri { get { - try { return this.responseUri; } - finally { CheckDisposed (); } + CheckDisposed (); + return this.responseUri; } } // Methods - [MonoTODO] - void ISerializable.GetObjectData (SerializationInfo serializationInfo, - StreamingContext streamingContext) + void ISerializable.GetObjectData (SerializationInfo serializationInfo, StreamingContext streamingContext) { - try { - throw new NotImplementedException (); - } finally { CheckDisposed (); } + SerializationInfo info = serializationInfo; + + info.AddValue ("responseUri", responseUri, typeof (Uri)); + info.AddValue ("contentLength", contentLength); + info.AddValue ("webHeaders", webHeaders, typeof (WebHeaderCollection)); } public override Stream GetResponseStream() { - try { return this.fileStream; } - finally { CheckDisposed (); } + CheckDisposed (); + return this.fileStream; } // Cleaning up stuff @@ -136,4 +137,4 @@ private void CheckDisposed () throw new ObjectDisposedException (GetType ().FullName); } } -} \ No newline at end of file +} diff --git a/mcs/class/System/System.Net/HttpRequestCreator.cs b/mcs/class/System/System.Net/HttpRequestCreator.cs index 7bdacc2257f93..52379e8ab2e48 100644 --- a/mcs/class/System/System.Net/HttpRequestCreator.cs +++ b/mcs/class/System/System.Net/HttpRequestCreator.cs @@ -11,6 +11,10 @@ namespace System.Net { class HttpRequestCreator : IWebRequestCreate { + internal HttpRequestCreator () + { + } + public WebRequest Create (Uri uri) { return new HttpWebRequest (uri); diff --git a/mcs/class/System/System.Net/HttpWebRequest.cs b/mcs/class/System/System.Net/HttpWebRequest.cs index cbb8d8ac34ba3..074b844e8a72c 100644 --- a/mcs/class/System/System.Net/HttpWebRequest.cs +++ b/mcs/class/System/System.Net/HttpWebRequest.cs @@ -72,10 +72,29 @@ internal HttpWebRequest (Uri uri) this.proxy = GlobalProxySelection.Select; } - [MonoTODO] protected HttpWebRequest (SerializationInfo serializationInfo, StreamingContext streamingContext) { - throw new NotImplementedException (); + SerializationInfo info = serializationInfo; + + requestUri = (Uri) info.GetValue ("requestUri", typeof (Uri)); + actualUri = (Uri) info.GetValue ("actualUri", typeof (Uri)); + allowAutoRedirect = info.GetBoolean ("allowAutoRedirect"); + allowBuffering = info.GetBoolean ("allowBuffering"); + certificates = (X509CertificateCollection) info.GetValue ("certificates", typeof (X509CertificateCollection)); + connectionGroup = info.GetString ("connectionGroup"); + contentLength = info.GetInt64 ("contentLength"); + webHeaders = (WebHeaderCollection) info.GetValue ("webHeaders", typeof (WebHeaderCollection)); + keepAlive = info.GetBoolean ("keepAlive"); + maxAutoRedirect = info.GetInt32 ("maxAutoRedirect"); + mediaType = info.GetString ("mediaType"); + method = info.GetString ("method"); + initialMethod = info.GetString ("initialMethod"); + pipelined = info.GetBoolean ("pipelined"); + version = (Version) info.GetValue ("version", typeof (Version)); + proxy = (IWebProxy) info.GetValue ("proxy", typeof (IWebProxy)); + sendChunked = info.GetBoolean ("sendChunked"); + timeout = info.GetInt32 ("timeout"); + redirects = info.GetInt32 ("redirects"); } // Properties @@ -645,11 +664,30 @@ public override void Abort () } } - [MonoTODO] void ISerializable.GetObjectData (SerializationInfo serializationInfo, StreamingContext streamingContext) { - throw new NotImplementedException (); + SerializationInfo info = serializationInfo; + + info.AddValue ("requestUri", requestUri, typeof (Uri)); + info.AddValue ("actualUri", actualUri, typeof (Uri)); + info.AddValue ("allowAutoRedirect", allowAutoRedirect); + info.AddValue ("allowBuffering", allowBuffering); + info.AddValue ("certificates", certificates, typeof (X509CertificateCollection)); + info.AddValue ("connectionGroup", connectionGroup); + info.AddValue ("contentLength", contentLength); + info.AddValue ("webHeaders", webHeaders, typeof (WebHeaderCollection)); + info.AddValue ("keepAlive", keepAlive); + info.AddValue ("maxAutoRedirect", maxAutoRedirect); + info.AddValue ("mediaType", mediaType); + info.AddValue ("method", method); + info.AddValue ("initialMethod", initialMethod); + info.AddValue ("pipelined", pipelined); + info.AddValue ("version", version, typeof (Version)); + info.AddValue ("proxy", proxy, typeof (IWebProxy)); + info.AddValue ("sendChunked", sendChunked); + info.AddValue ("timeout", timeout); + info.AddValue ("redirects", redirects); } void CheckRequestStarted () diff --git a/mcs/class/System/System.Net/HttpWebResponse.cs b/mcs/class/System/System.Net/HttpWebResponse.cs index 9c0c9c0e94ac7..bb4393d9e419c 100644 --- a/mcs/class/System/System.Net/HttpWebResponse.cs +++ b/mcs/class/System/System.Net/HttpWebResponse.cs @@ -27,7 +27,6 @@ public class HttpWebResponse : WebResponse, ISerializable, IDisposable Version version; HttpStatusCode statusCode; string statusDescription; - bool chunked; long contentLength = -1; string contentType; @@ -53,19 +52,18 @@ internal HttpWebResponse (Uri uri, string method, WebConnectionData data, bool c } } - [MonoTODO("Check this out and update if needed")] //Gon protected HttpWebResponse (SerializationInfo serializationInfo, StreamingContext streamingContext) { - uri = (Uri) serializationInfo.GetValue ("uri", typeof (Uri)); - webHeaders = (WebHeaderCollection) serializationInfo.GetValue ("webHeaders", - typeof (WebHeaderCollection)); - cookieCollection = (CookieCollection) serializationInfo.GetValue ("cookieCollection", - typeof (CookieCollection)); - method = serializationInfo.GetString ("method"); - version = (Version) serializationInfo.GetValue ("version", typeof (Version)); - statusCode = (HttpStatusCode) serializationInfo.GetValue ("statusCode", typeof (HttpStatusCode)); - statusDescription = serializationInfo.GetString ("statusDescription"); - chunked = serializationInfo.GetBoolean ("chunked"); + SerializationInfo info = serializationInfo; + + uri = (Uri) info.GetValue ("uri", typeof (Uri)); + contentLength = info.GetInt64 ("contentLength"); + contentType = info.GetString ("contentType"); + method = info.GetString ("method"); + statusDescription = info.GetString ("statusDescription"); + cookieCollection = (CookieCollection) info.GetValue ("cookieCollection", typeof (CookieCollection)); + version = (Version) info.GetValue ("version", typeof (Version)); + statusCode = (HttpStatusCode) info.GetValue ("statusCode", typeof (HttpStatusCode)); } // Properties @@ -227,15 +225,16 @@ public override Stream GetResponseStream () void ISerializable.GetObjectData (SerializationInfo serializationInfo, StreamingContext streamingContext) { - CheckDisposed (); - serializationInfo.AddValue ("uri", uri); - serializationInfo.AddValue ("webHeaders", webHeaders); - serializationInfo.AddValue ("cookieCollection", cookieCollection); - serializationInfo.AddValue ("method", method); - serializationInfo.AddValue ("version", version); - serializationInfo.AddValue ("statusCode", statusCode); - serializationInfo.AddValue ("statusDescription", statusDescription); - serializationInfo.AddValue ("chunked", chunked); + SerializationInfo info = serializationInfo; + + info.AddValue ("uri", uri); + info.AddValue ("contentLength", contentLength); + info.AddValue ("contentType", contentType); + info.AddValue ("method", method); + info.AddValue ("statusDescription", statusDescription); + info.AddValue ("cookieCollection", cookieCollection); + info.AddValue ("version", version); + info.AddValue ("statusCode", statusCode); } diff --git a/mcs/class/System/System.Net/WebConnection.cs b/mcs/class/System/System.Net/WebConnection.cs index 85c2e50ccc70c..c1b40b3ff4848 100644 --- a/mcs/class/System/System.Net/WebConnection.cs +++ b/mcs/class/System/System.Net/WebConnection.cs @@ -94,7 +94,7 @@ void HandleError (WebExceptionStatus st, Exception e) { status = st; Close (); - if (e == null) { // At least we noe where it comes from + if (e == null) { // At least we now where it comes from try { throw new Exception (); } catch (Exception e2) { @@ -541,6 +541,11 @@ void Abort (object sender, EventArgs args) { HandleError (WebExceptionStatus.RequestCanceled, null); } + + ~WebConnection () + { + Close (); + } } } diff --git a/mcs/class/System/System.Net/WebRequest.cs b/mcs/class/System/System.Net/WebRequest.cs index 22689725dbbb5..93efc666455ac 100644 --- a/mcs/class/System/System.Net/WebRequest.cs +++ b/mcs/class/System/System.Net/WebRequest.cs @@ -77,7 +77,6 @@ protected WebRequest (SerializationInfo serializationInfo, StreamingContext stre public virtual Uri RequestUri { get { throw new NotSupportedException (); } - set { throw new NotSupportedException (); } } public virtual int Timeout { @@ -207,7 +206,7 @@ internal static void AddPrefix (string prefix, string typeName) if (type == null) throw new ConfigurationException (String.Format ("Type {0} not found", typeName)); - object o = Activator.CreateInstance (type); + object o = Activator.CreateInstance (type, true); prefixes [prefix] = o; } }