public MimeType Resolve(IMessageHeaders headers)
        {
            if (headers == null || !headers.ContainsKey(MessageHeaders.CONTENT_TYPE))
            {
                return(DefaultMimeType);
            }

            var value = headers[MessageHeaders.CONTENT_TYPE];

            if (value == null)
            {
                return(null);
            }
            else if (value is MimeType mimeType)
            {
                return(mimeType);
            }
            else if (value is string stringVal)
            {
                return(MimeType.ToMimeType(stringVal));
            }
            else
            {
                throw new ArgumentException("Unknown type for contentType header value: " + value.GetType());
            }
        }
Beispiel #2
0
        protected bool ContainsReadOnly(IMessageHeaders headers)
        {
            if (_readOnlyHeaders != null)
            {
                foreach (var readOnly in _readOnlyHeaders)
                {
                    if (headers.ContainsKey(readOnly))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }