diff options
author | Atsushi Eno <atsushi@ximian.com> | 2011-06-13 15:05:27 +0400 |
---|---|---|
committer | Atsushi Eno <atsushi@ximian.com> | 2011-06-13 15:05:27 +0400 |
commit | 8219d05935eb1750610ef4f1eac8436a933d7dd5 (patch) | |
tree | 11a99b9bb598dac1448ad336d5d8fee36acdfa0f /mcs/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher | |
parent | 1060b4febb387bd3dd1ae0127e8e71cdd1171017 (diff) |
Implement OnWriteBodyContents() and add message buffer support for RawMessage.
Diffstat (limited to 'mcs/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher')
-rw-r--r-- | mcs/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/WebMessageFormatter.cs | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/mcs/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/WebMessageFormatter.cs b/mcs/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/WebMessageFormatter.cs index 7ad2d99e8c2..9553f2854c0 100644 --- a/mcs/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/WebMessageFormatter.cs +++ b/mcs/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/WebMessageFormatter.cs @@ -604,7 +604,48 @@ namespace System.ServiceModel.Dispatcher protected override void OnWriteBodyContents (XmlDictionaryWriter writer) { - throw new NotSupportedException (); + writer.WriteString ("-- message body is raw binary --"); + } + + protected override MessageBuffer OnCreateBufferedCopy (int maxBufferSize) + { + var ms = Stream as MemoryStream; + if (ms == null) { + ms = new MemoryStream (); + Stream.CopyTo (ms); + this.Stream = ms; + } + return new RawMessageBuffer (ms.ToArray (), headers, properties); + } + } + + internal class RawMessageBuffer : MessageBuffer + { + byte [] buffer; + MessageHeaders headers; + MessageProperties properties; + + public RawMessageBuffer (byte [] buffer, MessageHeaders headers, MessageProperties properties) + { + this.buffer = buffer; + this.headers = new MessageHeaders (headers); + this.properties = new MessageProperties (properties); + } + + public override int BufferSize { + get { return buffer.Length; } + } + + public override void Close () + { + } + + public override Message CreateMessage () + { + var msg = new RawMessage (new MemoryStream (buffer)); + msg.Headers.CopyHeadersFrom (headers); + msg.Properties.CopyProperties (properties); + return msg; } } } |