Merge pull request #409 from Alkarex/patch-1
[mono.git] / mcs / class / System / System.Net / WebConnectionStream.cs
index 132ceacbbce43079f87f0a3e6a823faca37a1f8e..ff370e9e8ba78d1e6f6275a49b9f6cb34570def0 100644 (file)
@@ -70,6 +70,12 @@ namespace System.Net
 
                public WebConnectionStream (WebConnection cnc)
                {
+                       if (cnc.Data == null)
+                               throw new InvalidOperationException ("cnc.Data was not initialized");
+                       if (cnc.Data.Headers == null)
+                               throw new InvalidOperationException ("cnc.Data.Headers was not initialized");
+                       if (cnc.Data.request == null)
+                               throw new InvalidOperationException ("cnc.Data.request was not initialized");
                        isRead = true;
                        cb_wrapper = new AsyncCallback (ReadCallbackWrapper);
                        pending = new ManualResetEvent (true);
@@ -137,16 +143,11 @@ namespace System.Net
                internal WebConnection Connection {
                        get { return cnc; }
                }
-#if NET_2_0
                public override bool CanTimeout {
                        get { return true; }
                }
-#endif
 
-#if NET_2_0
-               public override
-#endif
-               int ReadTimeout {
+               public override int ReadTimeout {
                        get {
                                return read_timeout;
                        }
@@ -158,10 +159,7 @@ namespace System.Net
                        }
                }
 
-#if NET_2_0
-               public override
-#endif
-               int WriteTimeout {
+               public override int WriteTimeout {
                        get {
                                return write_timeout;
                        }
@@ -643,8 +641,11 @@ namespace System.Net
                        long cl = request.ContentLength;
                        string method = request.Method;
                        bool no_writestream = (method == "GET" || method == "CONNECT" || method == "HEAD" ||
-                                               method == "TRACE" || method == "DELETE");
-                       if (sendChunked || cl > -1 || no_writestream) {
+                                               method == "TRACE");
+                       bool webdav = (method == "PROPFIND" || method == "PROPPATCH" || method == "MKCOL" ||
+                                      method == "COPY" || method == "MOVE" || method == "LOCK" ||
+                                      method == "UNLOCK");
+                       if (sendChunked || cl > -1 || no_writestream || webdav) {
                                WriteHeaders ();
                                if (!initRead) {
                                        initRead = true;
@@ -703,7 +704,7 @@ namespace System.Net
                        if (!headersSent) {
                                string method = request.Method;
                                bool no_writestream = (method == "GET" || method == "CONNECT" || method == "HEAD" ||
-                                                       method == "TRACE" || method == "DELETE");
+                                                       method == "TRACE");
                                if (!no_writestream)
                                        request.InternalContentLength = length;
                                request.SendRequestHeaders (true);