diff --git a/CefSharp/ResourceHandler.cs b/CefSharp/ResourceHandler.cs index d05edaeb5..276879862 100644 --- a/CefSharp/ResourceHandler.cs +++ b/CefSharp/ResourceHandler.cs @@ -62,31 +62,6 @@ namespace CefSharp MimeType = mimeType; } - /// - /// Initializes a new instance of the class. - /// - /// A stream of the resource. - public ResourceHandler(Stream stream) - { - StatusCode = 200; - StatusText = "OK"; - MimeType = "text/html"; - Stream = stream; - } - - /// - /// Initializes a new instance of the class. - /// - /// A stream of the resource. - /// Type of MIME. - public ResourceHandler(Stream stream, string mimeType) - { - StatusCode = 200; - StatusText = "OK"; - MimeType = mimeType; - Stream = stream; - } - /// /// Gets the resource from the file. /// @@ -144,6 +119,27 @@ namespace CefSharp return new ResourceHandler { Stream = GetStream(text, encoding, includePreamble) }; } + /// + /// Gets the resource from a stream. + /// + /// A stream of the resource. + /// + public static ResourceHandler FromStream(Stream stream) + { + return new ResourceHandler() { Stream = stream }; + } + + /// + /// Gets the resource from a stream. + /// + /// A stream of the resource. + /// Type of MIME. + /// + public static ResourceHandler FromStream(Stream stream, string mimeType) + { + return new ResourceHandler(mimeType) { Stream = stream }; + } + private static MemoryStream GetStream(string text, Encoding encoding, bool includePreamble) { if (includePreamble)