Beispiel #1
0
        internal async Task <Message> ParseIncomingResponse(TimeoutHelper timeoutHelper)
        {
            ValidateAuthentication();
            ValidateResponseStatusCode();
            bool hasContent = await ValidateContentTypeAsync(timeoutHelper);

            Message message = null;

            if (!hasContent)
            {
                if (_encoder.MessageVersion == MessageVersion.None)
                {
                    message = new NullMessage();
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                message = await ReadStreamAsMessageAsync(timeoutHelper);
            }

            var exception = ProcessHttpAddressing(message);

            Contract.Assert(exception == null, "ProcessHttpAddressing should not set an exception after parsing a response message.");

            return(message);
        }
        internal async Task<Message> ParseIncomingResponse()
        {
            ValidateAuthentication();
            ValidateResponseStatusCode();
            bool hasContent = await ValidateContentTypeAsync();
            Message message = null;

            if (!hasContent)
            {
                if (_encoder.MessageVersion == MessageVersion.None)
                {
                    message = new NullMessage();
                }
                else
                {
                    return null;
                }
            }
            else
            {
                message = await ReadStreamAsMessageAsync();
            }

            var exception = ProcessHttpAddressing(message);
            Contract.Assert(exception == null, "ProcessHttpAddressing should not set an exception after parsing a response message.");

            return message;
        }
        public Message ParseIncomingMessage(out Exception requestException)
        {
            Message message = null;
            Message message2;

            requestException = null;
            bool flag = true;

            try
            {
                this.ValidateContentType();
                ServiceModelActivity activity = null;
                if (DiagnosticUtility.ShouldUseActivity && ((ServiceModelActivity.Current == null) || (ServiceModelActivity.Current.ActivityType != ActivityType.ProcessAction)))
                {
                    activity = ServiceModelActivity.CreateBoundedActivity(true);
                }
                using (activity)
                {
                    if (DiagnosticUtility.ShouldUseActivity && (activity != null))
                    {
                        ServiceModelActivity.Start(activity, System.ServiceModel.SR.GetString("ActivityProcessingMessage", new object[] { TraceUtility.RetrieveMessageNumber() }), ActivityType.ProcessMessage);
                    }
                    if (!this.HasContent)
                    {
                        if (this.messageEncoder.MessageVersion != MessageVersion.None)
                        {
                            return(null);
                        }
                        message = new NullMessage();
                    }
                    else if (this.streamed)
                    {
                        message = this.ReadStreamedMessage(this.InputStream);
                    }
                    else if (this.ContentLength == -1L)
                    {
                        message = this.ReadChunkedBufferedMessage(this.InputStream);
                    }
                    else
                    {
                        message = this.ReadBufferedMessage(this.InputStream);
                    }
                    requestException = this.ProcessHttpAddressing(message);
                    flag             = false;
                    message2         = message;
                }
            }
            finally
            {
                if (flag)
                {
                    this.Close();
                }
            }
            return(message2);
        }
 private Message CreateAckMessage(HttpStatusCode statusCode, string statusDescription)
 {
     Message message = new NullMessage();
     HttpResponseMessageProperty property = new HttpResponseMessageProperty {
         StatusCode = statusCode,
         SuppressEntityBody = true
     };
     if (statusDescription.Length > 0)
     {
         property.StatusDescription = statusDescription;
     }
     message.Properties.Add(HttpResponseMessageProperty.Name, property);
     return message;
 }
Beispiel #5
0
        private Message CreateAckMessage(HttpStatusCode statusCode, string statusDescription)
        {
            Message message = new NullMessage();
            HttpResponseMessageProperty property = new HttpResponseMessageProperty {
                StatusCode         = statusCode,
                SuppressEntityBody = true
            };

            if (statusDescription.Length > 0)
            {
                property.StatusDescription = statusDescription;
            }
            message.Properties.Add(HttpResponseMessageProperty.Name, property);
            return(message);
        }
Beispiel #6
0
        Message CreateAckMessage(HttpStatusCode statusCode, string statusDescription)
        {
            Message ackMessage = new NullMessage();
            HttpResponseMessageProperty httpResponseProperty = new HttpResponseMessageProperty();

            httpResponseProperty.StatusCode         = statusCode;
            httpResponseProperty.SuppressEntityBody = true;
            if (statusDescription.Length > 0)
            {
                httpResponseProperty.StatusDescription = statusDescription;
            }

            ackMessage.Properties.Add(HttpResponseMessageProperty.Name, httpResponseProperty);

            return(ackMessage);
        }
        public override Message CreateMessage()
        {
            if (_closed)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(CreateBufferDisposedException());
            }

            Message msg;

            if (_isNullMessage)
            {
                msg = new NullMessage();
            }
            else
            {
                msg = Message.CreateMessage(_msgBuffer.GetReader(0), int.MaxValue, _version);
            }

            lock (ThisLock)
            {
                msg.Properties.CopyProperties(_properties);
            }

            for (int i = 0; i < _understoodHeaders.Length; ++i)
            {
                if (_understoodHeaders[i])
                {
                    msg.Headers.AddUnderstood(i);
                }
            }

            if (_to != null)
            {
                msg.Headers.To = _to;
            }

            if (_action != null)
            {
                msg.Headers.Action = _action;
            }

            return(msg);
        }
        public override Message CreateMessage()
        {
            Message message;

            if (this.closed)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(base.CreateBufferDisposedException());
            }
            if (this.isNullMessage)
            {
                message = new NullMessage();
            }
            else
            {
                message = Message.CreateMessage(this.msgBuffer.GetReader(0), 0x7fffffff, this.version);
            }
            lock (this.ThisLock)
            {
                message.Properties.CopyProperties(this.properties);
            }
            for (int i = 0; i < this.understoodHeaders.Length; i++)
            {
                if (this.understoodHeaders[i])
                {
                    message.Headers.AddUnderstood(i);
                }
            }
            if (this.to != null)
            {
                message.Headers.To = this.to;
            }
            if (this.action != null)
            {
                message.Headers.Action = this.action;
            }
            return(message);
        }
 public override Message CreateMessage()
 {
     Message message;
     if (this.closed)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(base.CreateBufferDisposedException());
     }
     if (this.isNullMessage)
     {
         message = new NullMessage();
     }
     else
     {
         message = Message.CreateMessage(this.msgBuffer.GetReader(0), 0x7fffffff, this.version);
     }
     lock (this.ThisLock)
     {
         message.Properties.CopyProperties(this.properties);
     }
     for (int i = 0; i < this.understoodHeaders.Length; i++)
     {
         if (this.understoodHeaders[i])
         {
             message.Headers.AddUnderstood(i);
         }
     }
     if (this.to != null)
     {
         message.Headers.To = this.to;
     }
     if (this.action != null)
     {
         message.Headers.Action = this.action;
     }
     return message;
 }
Beispiel #10
0
        public Message ParseIncomingMessage(HttpRequestMessage httpRequestMessage, out Exception requestException)
        {
            Message message = null;
            requestException = null;
            bool throwing = true;
            try
            {
                ValidateContentType();

                ServiceModelActivity activity = null;
                if (DiagnosticUtility.ShouldUseActivity &&
                    ((ServiceModelActivity.Current == null) ||
                     (ServiceModelActivity.Current.ActivityType != ActivityType.ProcessAction)))
                {
                    activity = ServiceModelActivity.CreateBoundedActivity(true);
                }
                using (activity)
                {
                    if (DiagnosticUtility.ShouldUseActivity && activity != null)
                    {
                        // Only update the Start identifier if the activity is not null.
                        ServiceModelActivity.Start(activity, SR.GetString(SR.ActivityProcessingMessage, TraceUtility.RetrieveMessageNumber()), ActivityType.ProcessMessage);
                    }

                    if (!this.HasContent)
                    {
                        if (this.messageEncoder.MessageVersion == MessageVersion.None)
                        {
                            message = new NullMessage();
                        }
                        else
                        {
                            return null;
                        }
                    }
                    else
                    {
                        Stream stream = this.GetInputStream(true);
                        if (streamed)
                        {
                            message = ReadStreamedMessage(stream);
                        }
                        else if (this.ContentLength == -1)
                        {
                            message = ReadChunkedBufferedMessage(stream);
                        }
                        else
                        {
                            if (httpRequestMessage == null)
                            {
                                message = ReadBufferedMessage(stream);
                            }
                            else
                            {
                                message = ReadBufferedMessage(httpRequestMessage);
                            }
                        }
                    }

                    requestException = ProcessHttpAddressing(message);

                    throwing = false;
                    return message;
                }
            }
            finally
            {
                if (throwing)
                {
                    Close();
                }
            }
        }
        Message CreateAckMessage(HttpStatusCode statusCode, string statusDescription)
        {
            Message ackMessage = new NullMessage();
            HttpResponseMessageProperty httpResponseProperty = new HttpResponseMessageProperty();
            httpResponseProperty.StatusCode = statusCode;
            httpResponseProperty.SuppressEntityBody = true;
            if (statusDescription.Length > 0)
            {
                httpResponseProperty.StatusDescription = statusDescription;
            }

            ackMessage.Properties.Add(HttpResponseMessageProperty.Name, httpResponseProperty);

            return ackMessage;
        }
Beispiel #12
0
        public override Message CreateMessage()
        {
            if (_closed)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(CreateBufferDisposedException());

            Message msg;
            if (_isNullMessage)
            {
                msg = new NullMessage();
            }
            else
            {
                msg = Message.CreateMessage(_msgBuffer.GetReader(0), int.MaxValue, _version);
            }

            lock (ThisLock)
            {
                msg.Properties.CopyProperties(_properties);
            }

            for (int i = 0; i < _understoodHeaders.Length; ++i)
            {
                if (_understoodHeaders[i])
                    msg.Headers.AddUnderstood(i);
            }

            if (_to != null)
            {
                msg.Headers.To = _to;
            }

            if (_action != null)
            {
                msg.Headers.Action = _action;
            }

            return msg;
        }
 public Message ParseIncomingMessage(out Exception requestException)
 {
     Message message = null;
     Message message2;
     requestException = null;
     bool flag = true;
     try
     {
         this.ValidateContentType();
         ServiceModelActivity activity = null;
         if (DiagnosticUtility.ShouldUseActivity && ((ServiceModelActivity.Current == null) || (ServiceModelActivity.Current.ActivityType != ActivityType.ProcessAction)))
         {
             activity = ServiceModelActivity.CreateBoundedActivity(true);
         }
         using (activity)
         {
             if (DiagnosticUtility.ShouldUseActivity && (activity != null))
             {
                 ServiceModelActivity.Start(activity, System.ServiceModel.SR.GetString("ActivityProcessingMessage", new object[] { TraceUtility.RetrieveMessageNumber() }), ActivityType.ProcessMessage);
             }
             if (!this.HasContent)
             {
                 if (this.messageEncoder.MessageVersion != MessageVersion.None)
                 {
                     return null;
                 }
                 message = new NullMessage();
             }
             else if (this.streamed)
             {
                 message = this.ReadStreamedMessage(this.InputStream);
             }
             else if (this.ContentLength == -1L)
             {
                 message = this.ReadChunkedBufferedMessage(this.InputStream);
             }
             else
             {
                 message = this.ReadBufferedMessage(this.InputStream);
             }
             requestException = this.ProcessHttpAddressing(message);
             flag = false;
             message2 = message;
         }
     }
     finally
     {
         if (flag)
         {
             this.Close();
         }
     }
     return message2;
 }
Beispiel #14
0
        public async Task<Message> ParseIncomingMessageAsync(HttpRequestMessage httpRequestMessage, OutWrapper<Exception> requestException)
        {
            Message message = null;
            requestException.Value = null;
            bool throwing = true;
            try
            {
                ValidateContentType();


                if (!this.HasContent)
                {
                    if (_messageEncoder.MessageVersion == MessageVersion.None)
                    {
                        message = new NullMessage();
                    }
                    else
                    {
                        return null;
                    }
                }
                else
                {
                    Stream stream = this.GetInputStream(true);
                    if (_streamed)
                    {
                        message = ReadStreamedMessage(stream);
                    }
                    else if (this.ContentLength == -1)
                    {
                        message = ReadChunkedBufferedMessage(stream);
                    }
                    else
                    {
                        if (httpRequestMessage == null)
                        {
                            message = await ReadBufferedMessageAsync(stream);
                        }
                        else
                        {
                            message = await ReadBufferedMessageAsync(httpRequestMessage);
                        }
                    }
                }

                requestException.Value = ProcessHttpAddressing(message);

                throwing = false;
                return message;
            }
            finally
            {
                if (throwing)
                {
                    Close();
                }
            }
        }