Author: atsushi
Date: 2008-02-15 12:33:04 -0500 (Fri, 15 Feb 2008)
New Revision: 95768

Modified:
   trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/ChangeLog
   
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/HttpRequestChannel.cs
Log:
2008-02-15  Atsushi Enomoto  <[EMAIL PROTECTED]>

        * HttpRequestChannel.cs : create WebRequest against To message header
          item (if exists).
          Consider HttpRequestMessageProperty.
          Do not output body when suppressed or the method is GET.



Modified: 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/ChangeLog
===================================================================
--- 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/ChangeLog    
    2008-02-15 17:24:31 UTC (rev 95767)
+++ 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/ChangeLog    
    2008-02-15 17:33:04 UTC (rev 95768)
@@ -1,5 +1,12 @@
 2008-02-15  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
+       * HttpRequestChannel.cs : create WebRequest against To message header
+         item (if exists).
+         Consider HttpRequestMessageProperty.
+         Do not output body when suppressed or the method is GET.
+
+2008-02-15  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
        * HttpChannelListener.cs : BindingContext may not have listenUri
          at its .ctor() step.
 

Modified: 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/HttpRequestChannel.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/HttpRequestChannel.cs
    2008-02-15 17:24:31 UTC (rev 95767)
+++ 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/HttpRequestChannel.cs
    2008-02-15 17:33:04 UTC (rev 95768)
@@ -84,6 +84,13 @@
 
                Message ProcessRequest (Message message, TimeSpan timeout)
                {
+                       // FIXME: is distination really like this?
+                       Uri destination = message.Headers.To ?? Via ?? 
RemoteAddress.Uri;
+
+                       web_request = HttpWebRequest.Create (destination);
+                       web_request.Method = "POST";
+                       web_request.ContentType = Encoder.ContentType;
+
                        web_request.Timeout = (int) timeout.TotalMilliseconds;
 
                        // There is no SOAP Action/To header when 
AddressingVersion is None.
@@ -93,22 +100,32 @@
                                        message.Headers.RemoveAll ("Action", 
message.Version.Addressing.Namespace);
                                        if (message.Headers.Action != null) 
throw new Exception (message.Headers.Action);
                                }
+                       }
 
-                               // FIXME: "To" header might also need special
-                               // processing, but am not sure if it is fine
-                               // to create a new WebRequest.
+                       // apply HttpRequestMessageProperty if exists.
+                       bool suppressEntityBody = false;
+                       string pname = HttpRequestMessageProperty.Name;
+                       if (message.Properties.ContainsKey (pname)) {
+                               HttpRequestMessageProperty hp = 
(HttpRequestMessageProperty) message.Properties [pname];
+                               web_request.Headers.Add (hp.Headers);
+                               web_request.Method = hp.Method;
+                               // FIXME: do we have to handle hp.QueryString ?
+                               if (hp.SuppressEntityBody)
+                                       suppressEntityBody = true;
                        }
 
-                       MemoryStream buffer = new MemoryStream ();
-                       Encoder.WriteMessage (message, buffer);
+                       if (!suppressEntityBody && String.Compare 
(web_request.Method, "GET", StringComparison.OrdinalIgnoreCase) != 0) {
+                               MemoryStream buffer = new MemoryStream ();
+                               Encoder.WriteMessage (message, buffer);
 
-                       if (buffer.Length > int.MaxValue)
-                               throw new InvalidOperationException ("The 
argument message is too large.");
+                               if (buffer.Length > int.MaxValue)
+                                       throw new InvalidOperationException 
("The argument message is too large.");
 
-                       web_request.ContentLength = (int) buffer.Length;
-                       Stream requestStream = web_request.GetRequestStream ();
-                       requestStream.Write (buffer.GetBuffer (), 0, (int) 
buffer.Length);
-                       requestStream.Close ();
+                               web_request.ContentLength = (int) buffer.Length;
+                               Stream requestStream = 
web_request.GetRequestStream ();
+                               requestStream.Write (buffer.GetBuffer (), 0, 
(int) buffer.Length);
+                               requestStream.Close ();
+                       }
 
                        WebResponse res = web_request.GetResponse ();
                        try {
@@ -191,12 +208,6 @@
 
                protected override void OnOpen (TimeSpan timeout)
                {
-                       // FIXME: is distination really like this?
-                       Uri destination = Via != null ? Via : RemoteAddress.Uri;
-
-                       web_request = HttpWebRequest.Create (destination);
-                       web_request.Method = "POST";
-                       web_request.ContentType = Encoder.ContentType;
                }
 
                protected override IAsyncResult OnBeginOpen (TimeSpan timeout, 
AsyncCallback callback, object state)

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to