Ver Fonte

2009-07-28 Atsushi Enomoto <[email protected]>

	* OutgoingWebRequestContext.cs : implement.

	* WebMessageFormatter.cs : apply OutgoingRequest if available.


svn path=/trunk/mcs/; revision=138782
Atsushi Eno há 16 anos atrás
pai
commit
fb60368a09

+ 4 - 0
mcs/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/ChangeLog

@@ -1,3 +1,7 @@
+2009-07-28  Atsushi Enomoto  <[email protected]>
+
+	* WebMessageFormatter.cs : apply OutgoingRequest if available.
+
 2008-04-16  Atsushi Enomoto  <[email protected]>
 
 	* WebMessageFormatter.cs : now that ReadObject() verifies

+ 4 - 0
mcs/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/WebMessageFormatter.cs

@@ -194,6 +194,10 @@ namespace System.ServiceModel.Description
 
 				var hp = new HttpRequestMessageProperty ();
 				hp.Method = Info.Method;
+
+				// FIXME: isn't it always null?
+				if (WebOperationContext.Current != null)
+					WebOperationContext.Current.OutgoingRequest.Apply (hp);
 				// FIXME: set hp.SuppressEntityBody for some cases.
 				ret.Properties.Add (HttpRequestMessageProperty.Name, hp);
 

+ 4 - 0
mcs/class/System.ServiceModel.Web/System.ServiceModel.Web/ChangeLog

@@ -1,3 +1,7 @@
+2009-07-28  Atsushi Enomoto  <[email protected]>
+
+	* OutgoingWebRequestContext.cs : implement.
+
 2008-06-11  Noam Lampert <[email protected]>
 
 	* WebServiceHost.cs: Open endpoint on BaseAddress if necessary

+ 37 - 53
mcs/class/System.ServiceModel.Web/System.ServiceModel.Web/OutgoingWebRequestContext.cs

@@ -26,7 +26,9 @@
 // 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
 {
@@ -36,69 +38,51 @@ namespace System.ServiceModel.Web
 		{
 		}
 
-		[MonoTODO]
-		public string Accept {
-			get { throw new NotImplementedException (); }
-			set { throw new NotImplementedException (); }
-		}
+		public string Accept { get; set; }
 
-		[MonoTODO]
-		public long ContentLength {
-			get { throw new NotImplementedException (); }
-			set { throw new NotImplementedException (); }
-		}
+		public long ContentLength { get; set; }
 
-		[MonoTODO]
-		public string ContentType {
-			get { throw new NotImplementedException (); }
-			set { throw new NotImplementedException (); }
-		}
+		public string ContentType { get; set; }
 
-		[MonoTODO]
-		public WebHeaderCollection Headers {
-			get { throw new NotImplementedException (); }
-		}
+		public WebHeaderCollection Headers { get; private set; }
 
-		[MonoTODO]
-		public string IfMatch {
-			get { throw new NotImplementedException (); }
-			set { throw new NotImplementedException (); }
-		}
+		public string IfMatch { get; set; }
 
-		[MonoTODO]
-		public string IfModifiedSince {
-			get { throw new NotImplementedException (); }
-			set { throw new NotImplementedException (); }
-		}
+		public string IfModifiedSince { get; set; }
 
-		[MonoTODO]
-		public string IfNoneMatch {
-			get { throw new NotImplementedException (); }
-			set { throw new NotImplementedException (); }
-		}
+		public string IfNoneMatch { get; set; }
 
-		[MonoTODO]
-		public string IfUnmodifiedSince {
-			get { throw new NotImplementedException (); }
-			set { throw new NotImplementedException (); }
-		}
+		public string IfUnmodifiedSince { get; set; }
 
-		[MonoTODO]
-		public string Method {
-			get { throw new NotImplementedException (); }
-			set { throw new NotImplementedException (); }
-		}
+		public string Method { get; set; }
 
-		[MonoTODO]
-		public bool SuppressEntityBody {
-			get { throw new NotImplementedException (); }
-			set { throw new NotImplementedException (); }
-		}
+		public bool SuppressEntityBody { get; set; }
+
+		public string UserAgent { get; set; }
 
-		[MonoTODO]
-		public string UserAgent {
-			get { throw new NotImplementedException (); }
-			set { throw new NotImplementedException (); }
+		internal void Apply (HttpRequestMessageProperty hp)
+		{
+			hp.Headers.Add (Headers);
+			if (Accept != null)
+				hp.Headers ["Accept"] = Accept;
+			if (ContentLength > 0)
+				hp.Headers ["Content-Length"] = ContentLength.ToString (NumberFormatInfo.InvariantInfo);
+			if (ContentType != null)
+				hp.Headers ["Content-Type"] = ContentType;
+			if (IfMatch != null)
+				hp.Headers ["If-Match"] = IfMatch;
+			if (IfModifiedSince != null)
+				hp.Headers ["If-Modified-Since"] = IfModifiedSince;
+			if (IfNoneMatch != null)
+				hp.Headers ["If-None-Match"] = IfNoneMatch;
+			if (IfUnmodifiedSince != null)
+				hp.Headers ["If-Unmodified-Since"] = IfUnmodifiedSince;
+			if (Method != null)
+				hp.Method = Method;
+			if (SuppressEntityBody)
+				hp.SuppressEntityBody = true;
+			if (UserAgent != null)
+				hp.Headers ["User-Agent"] = UserAgent;
 		}
 	}
 }