Add not-working code for TransferMode support.
authorAtsushi Eno <atsushi@ximian.com>
Mon, 30 Aug 2010 09:15:26 +0000 (18:15 +0900)
committerAtsushi Eno <atsushi@ximian.com>
Mon, 30 Aug 2010 09:15:26 +0000 (18:15 +0900)
mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpContextInfo.cs
mcs/class/System.ServiceModel/System.ServiceModel.Channels.Http/HttpReplyChannel.cs

index 517a4c0e615f9187dbbe9bb787ddbf2fdf00eb07..5e21c07c086187f42c4122959e088f1636cb381a 100644 (file)
@@ -157,6 +157,7 @@ namespace System.ServiceModel.Channels.Http
 
        abstract class HttpRequestInfo
        {
+               public abstract long ContentLength64 { get; }
                public abstract NameValueCollection QueryString { get; }
                public abstract NameValueCollection Headers { get; }
                public abstract Uri Url { get; }
@@ -174,6 +175,9 @@ namespace System.ServiceModel.Channels.Http
                
                HttpListenerRequest req;
 
+               public override long ContentLength64 {
+                       get { return req.ContentLength64; }
+               }
                public override NameValueCollection QueryString {
                        get { return req.QueryString; }
                }
@@ -203,6 +207,9 @@ namespace System.ServiceModel.Channels.Http
                
                HttpRequest req;
 
+               public override long ContentLength64 {
+                       get { return req.ContentLength; }
+               }
                public override NameValueCollection QueryString {
                        get { return req.QueryString; }
                }
index 0770e6007dbfaf60c0fc5f2bedbd4824688586f5..916c06a86caf118751f6d3efc02af3ee193c5bba 100644 (file)
@@ -177,8 +177,29 @@ namespace System.ServiceModel.Channels.Http
                        // FIXME: supply maxSizeOfHeaders.
                        int maxSizeOfHeaders = 0x10000;
 
+#if false // FIXME: enable it, once duplex callback test gets passed.
+                       Stream stream = ctxi.Request.InputStream;
+                       if (source.Source.TransferMode == TransferMode.Buffered) {
+                               if (ctxi.Request.ContentLength64 <= 0)
+                                       throw new ArgumentException ("This HTTP channel is configured to use buffered mode, and thus expects Content-Length sent to the listener");
+                               long size = 0;
+                               var ms = new MemoryStream ();
+                               var buf = new byte [0x1000];
+                               while (size < ctxi.Request.ContentLength64) {
+                                       if ((size += stream.Read (buf, 0, 0x1000)) > source.Source.MaxBufferSize)
+                                               throw new QuotaExceededException ("Message quota exceeded");
+                                       ms.Write (buf, 0, (int) (size - ms.Length));
+                               }
+                               ms.Position = 0;
+                               stream = ms;
+                       }
+
+                       var msg = Encoder.ReadMessage (
+                               stream, maxSizeOfHeaders, ctxi.Request.ContentType);
+#else
                        var msg = Encoder.ReadMessage (
                                ctxi.Request.InputStream, maxSizeOfHeaders, ctxi.Request.ContentType);
+#endif
 
                        if (MessageVersion.Envelope.Equals (EnvelopeVersion.Soap11) ||
                            MessageVersion.Addressing.Equals (AddressingVersion.None)) {