internal static Encoding GetEncoding2(string contentType) { // default to old text/* behavior for non-application base if (!ContentType.IsApplication(contentType)) { return(GetEncoding(contentType)); } string charset = ContentType.GetCharset(contentType); Encoding e = null; try { if (charset != null && charset.Length > 0) { e = Encoding.GetEncoding(charset); } } catch (Exception ex) { if (ex is ThreadAbortException || ex is StackOverflowException || ex is OutOfMemoryException) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, typeof(RequestResponseUtils), "GetEncoding2", ex); } } // no default per application/* mime type return(e); }
internal static Encoding GetEncoding2(string contentType) { if (!ContentType.IsApplication(contentType)) { return(GetEncoding(contentType)); } string charset = ContentType.GetCharset(contentType); Encoding encoding = null; try { if ((charset != null) && (charset.Length > 0)) { encoding = Encoding.GetEncoding(charset); } } catch (Exception exception) { if (((exception is ThreadAbortException) || (exception is StackOverflowException)) || (exception is OutOfMemoryException)) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Warning, typeof(RequestResponseUtils), "GetEncoding2", exception); } } return(encoding); }