internal ChunkingMessage(MessageVersion version, string action, ChunkingReader reader, Guid messageId)
 {
     this.version        = version;
     this.chunkReader    = reader;
     this.properties     = new MessageProperties();
     this.headers        = new MessageHeaders(this.version);
     this.headers.Action = action;
     this.messageId      = messageId;
 }
 internal ChunkingMessage(MessageVersion version, string action, ChunkingReader reader, Guid messageId)
 {
     this.version = version;
     this.chunkReader = reader;
     this.properties = new MessageProperties();
     this.headers = new MessageHeaders(this.version);
     this.headers.Action = action;
     this.messageId = messageId;
 }
        ChunkingMessage GetNewChunkingMessage(Message receivedMessage, TimeoutHelper timeoutHelper)
        {
            if (receivedMessage == null)
            {
                //end of session
                return(null);
            }
            Guid messageId = GetMessageId(receivedMessage);

            if (this.currentInputMessage != null && messageId == this.currentInputMessage.MessageId)
            {
                throw new InvalidOperationException("A new ChunkingMessage was requested but the received message's id matches the current message id. The received message is a chunk of the current message");
            }
            ChunkingReader reader = new ChunkingReader(receivedMessage, this.maxBufferedChunks, timeoutHelper);

            string originalAction = receivedMessage.Headers.GetHeader <string>(
                ChunkingUtils.OriginalAction,
                ChunkingUtils.ChunkNs);
            ChunkingMessage dechunkedMessage = new ChunkingMessage(receivedMessage.Version, originalAction, reader, messageId);

            string addressingNs = ChunkingUtils.GetAddressingNamespace(receivedMessage.Version);

            //read original headers from body of startingChunk and add them to headers of dechunkedMessage
            for (int i = 0; i < receivedMessage.Headers.Count; i++)
            {
                MessageHeaderInfo headerInfo = receivedMessage.Headers[i];
                if (headerInfo.Namespace != ChunkingUtils.ChunkNs &&
                    !(headerInfo.Name == "Action" && headerInfo.Namespace == addressingNs))
                {
                    //not a chunking header and not the chunking wsa:Action header
                    //copy it to dechunkedMessage
                    dechunkedMessage.Headers.CopyHeaderFrom(
                        receivedMessage.Headers, i);
                }
            }
            return(dechunkedMessage);
        }