2005-01-31 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mcs / class / System.Web.Services / System.Web.Services.Protocols / WebClientProtocol.cs
index 9cc6fccbd7f193d7fcceff9ffc19ae91d4216908..65f0f0852597b8e4e67d6541a1121529caa2a9e0 100644 (file)
@@ -6,6 +6,27 @@
 //\r
 // Copyright (C) Tim Coleman, 2002\r
 //\r
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
 \r
 using System.Collections.Specialized;\r
 using System.ComponentModel;\r
@@ -30,7 +51,7 @@ namespace System.Web.Services.Protocols {
                //\r
                // Used by SoapHttpClientProtocol, use this to avoid creating a new Uri on each invocation.\r
                //\r
-               protected internal Uri uri;\r
+               internal Uri uri;\r
                        \r
                //\r
                // Points to the current request, so we can call Abort() on it\r
@@ -132,13 +153,16 @@ namespace System.Web.Services.Protocols {
 \r
                protected virtual WebRequest GetWebRequest (Uri uri)\r
                {\r
+                       if (uri == null)\r
+                               throw new InvalidOperationException ("uri is null");\r
+\r
                        current_request = WebRequest.Create (uri);\r
-                       current_request.Timeout = Timeout;\r
+                       current_request.Timeout = timeout;\r
+                       current_request.PreAuthenticate = preAuthenticate;\r
+                       current_request.ConnectionGroupName = connectionGroupName;\r
 \r
                        if (credentials != null)\r
                                current_request.Credentials = credentials;\r
-                       if (connectionGroupName != String.Empty)\r
-                               current_request.ConnectionGroupName = connectionGroupName;\r
 \r
                        return current_request;\r
                }\r
@@ -147,7 +171,18 @@ namespace System.Web.Services.Protocols {
                {\r
                        if (abort)\r
                                throw new WebException ("The operation has been aborted.", WebExceptionStatus.RequestCanceled);\r
-                       return request.GetResponse ();\r
+\r
+                       WebResponse response = null;\r
+                       try {\r
+                               request.Timeout = timeout;\r
+                               response = request.GetResponse ();\r
+                       } catch (WebException e) {\r
+                               response = e.Response;\r
+                               if (response == null)\r
+                                       throw;\r
+                       }\r
+\r
+                       return response;\r
                }\r
 \r
                protected virtual WebResponse GetWebResponse (WebRequest request, IAsyncResult result)\r
@@ -155,8 +190,6 @@ namespace System.Web.Services.Protocols {
                        if (abort)\r
                                throw new WebException ("The operation has been aborted.", WebExceptionStatus.RequestCanceled);\r
 \r
-                       IAsyncResult ar = request.BeginGetResponse (null, null);\r
-                       ar.AsyncWaitHandle.WaitOne ();\r
                        return request.EndGetResponse (result);\r
                }\r
 \r