Default implementation of IResourceHandler. This latest implementation provides some simplification, at a minimum you only need to override ProcessRequestAsync. See the project source on GitHub for working examples. used to implement a custom request handler interface. The methods of this class will always be called on the IO thread. Static helper methods are included like FromStream and FromString that make dealing with fixed resources easy.
Inheritance: IResourceHandler
Exemple #1
0
        void IResourceHandler.GetResponseHeaders(IResponse response, out long responseLength, out string redirectUrl)
        {
            responseLength = -1;
            redirectUrl    = null;

            response.StatusCode = _stream != null ? 200 : 404;
            response.StatusText = "OK";

            if (response.StatusCode == 200)
            {
                response.MimeType = CefResourceHandler.GetMimeType(Path.GetExtension(_resourcePath));
            }

            if (_stream?.CanSeek == true)
            {
                responseLength = _stream.Length;
            }
        }
 public virtual void RegisterHandler(string url, ResourceHandler handler)
 {
     Handlers[url] = handler;
 }
 /*
  * Handler for the browser register handler event.
  */
 public void RegisterHandler(string url, ResourceHandler handler) {
     // No implementation required
 }
 public virtual void RegisterHandler(string url, ResourceHandler handler)
 {
     Handlers[url] = handler;
 }
Exemple #5
0
 public void RespondWith(string filename)
 {
     CefSharp.ResourceHandler resourceHandler = (CefSharp.ResourceHandler)CefSharp.ResourceHandler.FromFilePath(filename, CefSharp.ResourceHandler.GetMimeType(Path.GetExtension(filename)), false);
     resourceHandler.AutoDisposeStream = true;
     this.Handler = resourceHandler;
 }