Author: atsushi
Date: 2008-02-17 09:48:47 -0500 (Sun, 17 Feb 2008)
New Revision: 95974

Modified:
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/ChangeLog
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/WebMessageFormatter.cs
   trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web/ChangeLog
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web/IncomingWebRequestContext.cs
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web/IncomingWebResponseContext.cs
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web/OutgoingWebRequestContext.cs
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web/OutgoingWebResponseContext.cs
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web/WebOperationContext.cs
Log:
2008-02-17  Atsushi Enomoto  <[EMAIL PROTECTED]>

        * WebMessageFormatter.cs : implement WebOperationContext support.

        * IncomingWebRequestContext.cs, IncomingWebResponseContext.cs,
          OutgoingWebRequestContext.cs, OutgoingWebResponseContext.cs,
          WebOperationContext.cs : implemented large chunk of them. Still
          not sure how outgoing request and incoming response are used.



Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/ChangeLog
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/ChangeLog
  2008-02-17 14:44:47 UTC (rev 95973)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/ChangeLog
  2008-02-17 14:48:47 UTC (rev 95974)
@@ -1,3 +1,7 @@
+2008-02-17  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * WebMessageFormatter.cs : implement WebOperationContext support.
+
 2008-02-16  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * WebHttpDispatchOperationSelector.cs : some code cleanup.

Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/WebMessageFormatter.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/WebMessageFormatter.cs
     2008-02-17 14:44:47 UTC (rev 95973)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/WebMessageFormatter.cs
     2008-02-17 14:48:47 UTC (rev 95974)
@@ -243,6 +243,16 @@
 
                        public Message SerializeReply (MessageVersion 
messageVersion, object [] parameters, object result)
                        {
+                               try {
+                                       return SerializeReplyCore 
(messageVersion, parameters, result);
+                               } finally {
+                                       if (WebOperationContext.Current != null)
+                                               
OperationContext.Current.Extensions.Remove (WebOperationContext.Current);
+                               }
+                       }
+
+                       Message SerializeReplyCore (MessageVersion 
messageVersion, object [] parameters, object result)
+                       {
                                if (parameters == null)
                                        throw new ArgumentNullException 
("parameters");
                                CheckMessageVersion (messageVersion);
@@ -279,6 +289,10 @@
                                var hp = new HttpResponseMessageProperty ();
                                // FIXME: get encoding from somewhere
                                hp.Headers ["Content-Type"] = mediaType + "; 
charset=utf-8";
+
+                               // apply user-customized HTTP results via 
WebOperationContext.
+                               
WebOperationContext.Current.OutgoingResponse.Apply (hp);
+
                                // FIXME: fill some properties if required.
                                ret.Properties.Add 
(HttpResponseMessageProperty.Name, hp);
 
@@ -294,11 +308,16 @@
                                        throw new ArgumentNullException 
("parameters");
                                CheckMessageVersion (message.Version);
 
+                               OperationContext.Current.Extensions.Add (new 
WebOperationContext (OperationContext.Current));
+
+                               IncomingWebRequestContext iwc = 
WebOperationContext.Current.IncomingRequest;
+
                                Uri to = message.Headers.To;
                                UriTemplateMatch match = UriTemplate.Match 
(Endpoint.Address.Uri, to);
                                if (match == null)
                                        // not sure if it could happen
                                        throw new SystemException 
(String.Format ("INTERNAL ERROR: UriTemplate does not match with the request: 
{0} / {1}", UriTemplate, to));
+                               iwc.UriTemplateMatch = match;
 
                                MessageDescription md = GetMessageDescription 
(MessageDirection.Input);
 

Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web/ChangeLog
===================================================================
--- trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web/ChangeLog 
2008-02-17 14:44:47 UTC (rev 95973)
+++ trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web/ChangeLog 
2008-02-17 14:48:47 UTC (rev 95974)
@@ -1,3 +1,10 @@
+2008-02-17  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * IncomingWebRequestContext.cs, IncomingWebResponseContext.cs,
+         OutgoingWebRequestContext.cs, OutgoingWebResponseContext.cs,
+         WebOperationContext.cs : implemented large chunk of them. Still
+         not sure how outgoing request and incoming response are used.
+
 2008-02-16  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * WebServiceHost.cs : Binding could be custom.

Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web/IncomingWebRequestContext.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web/IncomingWebRequestContext.cs
      2008-02-17 14:44:47 UTC (rev 95973)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web/IncomingWebRequestContext.cs
      2008-02-17 14:48:47 UTC (rev 95974)
@@ -26,46 +26,52 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 using System;
+using System.Globalization;
 using System.Net;
+using System.ServiceModel.Channels;
 
 namespace System.ServiceModel.Web
 {
        public class IncomingWebRequestContext
        {
-               [MonoTODO]
+               HttpRequestMessageProperty hp;
+               UriTemplateMatch match;
+
+               internal IncomingWebRequestContext (OperationContext context)
+               {
+                       hp = (HttpRequestMessageProperty) 
context.IncomingMessageProperties [HttpRequestMessageProperty.Name];
+               }
+
                public string Accept {
-                       get { throw new NotImplementedException (); }
+                       get { return hp.Headers.Get ("Accept"); }
                }
 
-               [MonoTODO]
                public long ContentLength {
-                       get { throw new NotImplementedException (); }
+                       get {
+                               string s = hp.Headers.Get ("Content-Length");
+                               return s != null ? long.Parse (s, 
CultureInfo.InvariantCulture) : 0;
+                       }
                }
 
-               [MonoTODO]
                public string ContentType {
-                       get { throw new NotImplementedException (); }
+                       get { return hp.Headers.Get ("Content-Type"); }
                }
 
-               [MonoTODO]
                public WebHeaderCollection Headers {
-                       get { throw new NotImplementedException (); }
+                       get { return hp.Headers; }
                }
 
-               [MonoTODO]
                public string Method {
-                       get { throw new NotImplementedException (); }
+                       get { return hp.Method; }
                }
 
-               [MonoTODO]
                public UriTemplateMatch UriTemplateMatch {
-                       get { throw new NotImplementedException (); }
-                       set { throw new NotImplementedException (); }
+                       get { return match; }
+                       set { match = value; }
                }
 
-               [MonoTODO]
                public string UserAgent {
-                       get { throw new NotImplementedException (); }
+                       get { return hp.Headers.Get ("User-Agent"); }
                }
        }
 }

Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web/IncomingWebResponseContext.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web/IncomingWebResponseContext.cs
     2008-02-17 14:44:47 UTC (rev 95973)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web/IncomingWebResponseContext.cs
     2008-02-17 14:48:47 UTC (rev 95974)
@@ -26,45 +26,50 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 using System;
+using System.Globalization;
 using System.Net;
+using System.ServiceModel.Channels;
 
 namespace System.ServiceModel.Web
 {
        public class IncomingWebResponseContext
        {
-               [MonoTODO]
+               HttpResponseMessageProperty hp;
+
+               internal IncomingWebResponseContext (OperationContext context)
+               {
+                       hp = (HttpResponseMessageProperty) 
context.IncomingMessageProperties [HttpResponseMessageProperty.Name];
+               }
+
                public long ContentLength {
-                       get { throw new NotImplementedException (); }
+                       get {
+                               string s = hp.Headers.Get ("Content-Length");
+                               return s != null ? long.Parse (s, 
CultureInfo.InvariantCulture) : 0;
+                       }
                }
 
-               [MonoTODO]
                public string ContentType {
-                       get { throw new NotImplementedException (); }
+                       get { return hp.Headers.Get ("Content-Type"); }
                }
 
-               [MonoTODO]
                public string ETag {
-                       get { throw new NotImplementedException (); }
+                       get { return hp.Headers.Get ("ETag"); }
                }
 
-               [MonoTODO]
                public WebHeaderCollection Headers {
-                       get { throw new NotImplementedException (); }
+                       get { return hp.Headers; }
                }
 
-               [MonoTODO]
                public string Location {
-                       get { throw new NotImplementedException (); }
+                       get { return hp.Headers.Get ("Location"); }
                }
 
-               [MonoTODO]
                public HttpStatusCode StatusCode {
-                       get { throw new NotImplementedException (); }
+                       get { return hp.StatusCode; }
                }
 
-               [MonoTODO]
                public string StatusDescription {
-                       get { throw new NotImplementedException (); }
+                       get { return hp.StatusDescription; }
                }
        }
 }

Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web/OutgoingWebRequestContext.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web/OutgoingWebRequestContext.cs
      2008-02-17 14:44:47 UTC (rev 95973)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web/OutgoingWebRequestContext.cs
      2008-02-17 14:48:47 UTC (rev 95974)
@@ -32,6 +32,10 @@
 {
        public class OutgoingWebRequestContext
        {
+               internal OutgoingWebRequestContext ()
+               {
+               }
+
                [MonoTODO]
                public string Accept {
                        get { throw new NotImplementedException (); }

Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web/OutgoingWebResponseContext.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web/OutgoingWebResponseContext.cs
     2008-02-17 14:44:47 UTC (rev 95973)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web/OutgoingWebResponseContext.cs
     2008-02-17 14:48:47 UTC (rev 95974)
@@ -26,63 +26,92 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 using System;
+using System.Globalization;
 using System.Net;
+using System.ServiceModel.Channels;
 
 namespace System.ServiceModel.Web
 {
        public class OutgoingWebResponseContext
        {
-               [MonoTODO]
+               WebHeaderCollection headers;
+               long content_length;
+               string content_type, etag, location, status_desc;
+               DateTime last_modified;
+               HttpStatusCode status_code;
+               bool suppress_body;
+
+               internal OutgoingWebResponseContext ()
+               {
+               }
+
+               internal void Apply (HttpResponseMessageProperty hp)
+               {
+                       if (headers != null)
+                               hp.Headers.Add (headers);
+                       if (content_length != 0)
+                               hp.Headers ["Content-Length"] = 
content_length.ToString (NumberFormatInfo.InvariantInfo);
+                       if (content_type != null)
+                               hp.Headers ["Content-Type"] = content_type;
+                       if (etag != null)
+                               hp.Headers ["ETag"] = etag;
+                       if (location != null)
+                               hp.Headers ["Location"] = location;
+                       if (last_modified != default (DateTime))
+                               hp.Headers ["Last-Modified"] = 
last_modified.ToString ("R");
+                       if (status_code != default (HttpStatusCode))
+                               hp.StatusCode = status_code;
+                       if (status_desc != null)
+                               hp.StatusDescription = status_desc;
+                       hp.SuppressEntityBody = suppress_body;
+               }
+
                public long ContentLength {
-                       get { throw new NotImplementedException (); }
-                       set { throw new NotImplementedException (); }
+                       get { return content_length; }
+                       set { content_length = value; }
                }
 
-               [MonoTODO]
                public string ContentType {
-                       get { throw new NotImplementedException (); }
-                       set { throw new NotImplementedException (); }
+                       get { return content_type; }
+                       set { content_type = value; }
                }
 
-               [MonoTODO]
                public string ETag {
-                       get { throw new NotImplementedException (); }
-                       set { throw new NotImplementedException (); }
+                       get { return etag; }
+                       set { etag = value; }
                }
 
-               [MonoTODO]
                public WebHeaderCollection Headers {
-                       get { throw new NotImplementedException (); }
+                       get {
+                               if (headers == null)
+                                       headers = new WebHeaderCollection ();
+                               return headers;
+                       }
                }
 
-               [MonoTODO]
                public DateTime LastModified {
-                       get { throw new NotImplementedException (); }
-                       set { throw new NotImplementedException (); }
+                       get { return last_modified; }
+                       set { last_modified = value; }
                }
 
-               [MonoTODO]
                public string Location {
-                       get { throw new NotImplementedException (); }
-                       set { throw new NotImplementedException (); }
+                       get { return location; }
+                       set { location = value; }
                }
 
-               [MonoTODO]
                public HttpStatusCode StatusCode {
-                       get { throw new NotImplementedException (); }
-                       set { throw new NotImplementedException (); }
+                       get { return status_code; }
+                       set { status_code = value; }
                }
 
-               [MonoTODO]
                public string StatusDescription {
-                       get { throw new NotImplementedException (); }
-                       set { throw new NotImplementedException (); }
+                       get { return status_desc; }
+                       set { status_desc = value; }
                }
 
-               [MonoTODO]
                public bool SuppressEntityBody {
-                       get { throw new NotImplementedException (); }
-                       set { throw new NotImplementedException (); }
+                       get { return suppress_body; }
+                       set { suppress_body = value; }
                }
        }
 }

Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web/WebOperationContext.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web/WebOperationContext.cs
    2008-02-17 14:44:47 UTC (rev 95973)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web/WebOperationContext.cs
    2008-02-17 14:48:47 UTC (rev 95974)
@@ -38,35 +38,33 @@
                        get { return OperationContext.Current != null ? 
OperationContext.Current.Extensions.Find<WebOperationContext> () : null; }
                }
 
-               OperationContext operation;
-               IncomingWebRequestContext incoming_request = new 
IncomingWebRequestContext ();
-               IncomingWebResponseContext incoming_response = new 
IncomingWebResponseContext ();
-               OutgoingWebRequestContext outgoing_request = new 
OutgoingWebRequestContext ();
-               OutgoingWebResponseContext outgoing_response = new 
OutgoingWebResponseContext ();
+               IncomingWebRequestContext incoming_request;
+               IncomingWebResponseContext incoming_response;
+               OutgoingWebRequestContext outgoing_request;
+               OutgoingWebResponseContext outgoing_response;
 
                public WebOperationContext (OperationContext operation)
                {
                        if (operation == null)
                                throw new ArgumentNullException ("operation");
-                       this.operation = operation;
+                       incoming_request = new IncomingWebRequestContext 
(operation);
+                       incoming_response = new IncomingWebResponseContext 
(operation);
+                       outgoing_request = new OutgoingWebRequestContext ();
+                       outgoing_response = new OutgoingWebResponseContext ();
                }
 
-               [MonoTODO]
                public IncomingWebRequestContext IncomingRequest {
                        get { return incoming_request; }
                }
 
-               [MonoTODO]
                public IncomingWebResponseContext IncomingResponse {
                        get { return incoming_response; }
                }
 
-               [MonoTODO]
                public OutgoingWebRequestContext OutgoingRequest {
                        get { return outgoing_request; }
                }
 
-               [MonoTODO]
                public OutgoingWebResponseContext OutgoingResponse {
                        get { return outgoing_response; }
                }

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

Reply via email to