diff --git a/Aspects/RegularExpression.cs b/Aspects/RegularExpression.cs
index e8504f6..05aeff2 100644
--- a/Aspects/RegularExpression.cs
+++ b/Aspects/RegularExpression.cs
@@ -574,18 +574,31 @@ public static class RegularExpression
#region Guid
///
- /// Regular expression pattern which matches ...
+ /// Regular expression pattern which matches GUID.
///
public const string RexGuid = @"(?i:^(?:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})|(?:[0-9a-f]{32})$)";
readonly static Lazy _rexGuid = new Lazy(() => new Regex(RexGuid, RegexOptions.Compiled));
///
- /// Gets a Regex object which matches ...
+ /// Gets a Regex object which matches GUID
///
public static Regex Guid => _rexGuid.Value;
#endregion
+ #region Content-type or Accepts header values:
+ ///
+ /// Regular expression pattern which matches the value of the HTTP headers Accept and content-type, incl. vendor specific MIME types.
+ ///
+ public const string RexContentType = @"(?i:)^(?text|application)/(?:(?[^\s,;+-]+)(?:-(?[^\s,;+]+))?\+)?(?[^\s\+,;]+)$";
+
+ readonly static Lazy _contentType = new Lazy(() => new Regex(RexContentType, RegexOptions.Compiled));
+
+ ///
+ /// Regular expression pattern which matches the value of the HTTP headers Accept and content-type, incl. vendor specific MIME types.
+ ///
+ public static Regex ContentType => _contentType.Value;
+ #endregion
#region ByteArray
///
diff --git a/Aspects/Wcf/Bindings/WebContentTypeMapperDefaultJson.cs b/Aspects/Wcf/Bindings/WebContentTypeMapperDefaultJson.cs
index c08695d..f00df57 100644
--- a/Aspects/Wcf/Bindings/WebContentTypeMapperDefaultJson.cs
+++ b/Aspects/Wcf/Bindings/WebContentTypeMapperDefaultJson.cs
@@ -1,5 +1,4 @@
-using System;
-using System.ServiceModel.Channels;
+using System.ServiceModel.Channels;
namespace vm.Aspects.Wcf.Bindings
{
@@ -19,12 +18,20 @@ public override WebContentFormat GetMessageFormatForContentType(
if (string.IsNullOrWhiteSpace(contentType))
return WebContentFormat.Default;
- if (contentType.StartsWith("text/javascript", StringComparison.OrdinalIgnoreCase) ||
- contentType.StartsWith("text/plain", StringComparison.OrdinalIgnoreCase))
- return WebContentFormat.Json;
+ var match = RegularExpression.ContentType.Match(contentType);
- if (contentType.StartsWith("text/xml", StringComparison.OrdinalIgnoreCase))
- return WebContentFormat.Xml;
+ if (match.Success)
+ switch (match.Groups["format"].Value.ToUpperInvariant())
+ {
+ case "JAVASCRIPT":
+ case "JSON":
+ case "X-JAVASCRIPT":
+ case "X-JSON":
+ return WebContentFormat.Json;
+
+ case "XML":
+ return WebContentFormat.Xml;
+ }
return WebContentFormat.Default;
}