ServiceStack.HttpResponseExtensionsInternal.WriteBytesToResponse C# (CSharp) Метод

WriteBytesToResponse() публичный статический Метод

public static WriteBytesToResponse ( this res, byte responseBytes, string contentType ) : void
res this
responseBytes byte
contentType string
Результат void
        public static void WriteBytesToResponse(this IResponse res, byte[] responseBytes, string contentType)
        {
            res.ContentType = HostContext.Config.AppendUtf8CharsetOnContentTypes.Contains(contentType)
                ? contentType + ContentFormat.Utf8Suffix
                : contentType;

            res.ApplyGlobalResponseHeaders();
            res.SetContentLength(responseBytes.Length);

            try
            {
                res.OutputStream.Write(responseBytes, 0, responseBytes.Length);
                res.Flush();
            }
            catch (Exception ex)
            {
                ex.HandleResponseWriteException(res.Request, res, contentType);
            }
            finally
            {
                res.EndRequest(skipHeaders: true);
            }
        }