protected override bool ProcessRequest(CefRequest request, CefCallback callback)
        {
            var requestNo = Interlocked.Increment(ref _requestNo);
            
            var response = new StringBuilder();

            response.AppendFormat("<pre>\n");
            response.AppendFormat("Requests processed by DemoAppResourceHandler: {0}\n", requestNo);

            response.AppendFormat("Method: {0}\n", request.Method);
            response.AppendFormat("URL: {0}\n", request.Url);

            response.AppendLine();
            response.AppendLine("Headers:");
            var headers = request.GetHeaderMap();
            foreach (string key in headers)
            {
                foreach (var value in headers.GetValues(key))
                {
                    response.AppendFormat("{0}: {1}\n", key, value);
                }
            }
            response.AppendLine();

            response.AppendFormat("</pre>\n");

            responseData = Encoding.UTF8.GetBytes(response.ToString());

            callback.Continue();
            return true;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create a new URL request. Only GET, POST, HEAD, DELETE and PUT request
        /// methods are supported. Multiple post data elements are not supported and
        /// elements of type PDE_TYPE_FILE are only supported for requests originating
        /// from the browser process. Requests originating from the render process will
        /// receive the same handling as requests originating from Web content -- if
        /// the response contains Content-Disposition or Mime-Type header values that
        /// would not normally be rendered then the response may receive special
        /// handling inside the browser (for example, via the file download code path
        /// instead of the URL request code path). The |request| object will be marked
        /// as read-only after calling this method.
        /// </summary>
        public static CefUrlRequest Create(CefRequest request, CefUrlRequestClient client)
        {
            if (request == null) throw new ArgumentNullException("request");

            var n_request = request.ToNative();
            var n_client = client.ToNative();

            return CefUrlRequest.FromNative(
                cef_urlrequest_t.create(n_request, n_client)
                );
        }
Exemplo n.º 3
0
 /// <summary>
 /// Begin processing the request. To handle the request return true and call
 /// CefCallback::Continue() once the response header information is available
 /// (CefCallback::Continue() can also be called from inside this method if
 /// header information is available immediately). To cancel the request return
 /// false.
 /// </summary>
 protected abstract bool ProcessRequest(CefRequest request, CefCallback callback);
Exemplo n.º 4
0
        /// <summary>
        /// Load the request represented by the |request| object.
        /// </summary>
        public void LoadRequest(CefRequest request)
        {
            if (request == null) throw new ArgumentNullException("request");

            cef_frame_t.load_request(_self, request.ToNative());
        }
Exemplo n.º 5
0
 /// <summary>
 /// Returns the request object used to create this URL request. The returned
 /// object is read-only and should not be modified.
 /// </summary>
 public CefRequest GetRequest()
 {
     return(CefRequest.FromNative(
                cef_urlrequest_t.get_request(_self)
                ));
 }
 protected override bool OnBeforeResourceLoad(CefBrowser browser, CefFrame frame, CefRequest request)
 {
     return base.OnBeforeResourceLoad(browser, frame, request);
 }
 protected override bool OnBeforeBrowse(CefBrowser browser, CefFrame frame, CefRequest request, bool isRedirect)
 {
     webBrowser.selfRequest = request;
     return base.OnBeforeBrowse(browser, frame, request, isRedirect);
 }
 /// <summary>
 /// Return a new resource handler instance to handle the request or an empty
 /// reference to allow default handling of the request. |browser| and |frame|
 /// will be the browser window and frame respectively that originated the
 /// request or NULL if the request did not originate from a browser window
 /// (for example, if the request came from CefURLRequest). The |request| object
 /// passed to this method will not contain cookie data.
 /// </summary>
 protected abstract CefResourceHandler Create(CefBrowser browser, CefFrame frame, string schemeName, CefRequest request);
 protected override CefResourceHandler Create(CefBrowser browser, CefFrame frame, string schemeName, CefRequest request)
 {
     return new RequestResourceHandler();
 }
Exemplo n.º 10
0
 /// <summary>
 /// Called on the IO thread before a resource is loaded. To allow the resource
 /// to load normally return NULL. To specify a handler for the resource return
 /// a CefResourceHandler object. The |request| object should not be modified in
 /// this callback.
 /// </summary>
 protected virtual CefResourceHandler GetResourceHandler(CefBrowser browser, CefFrame frame, CefRequest request)
 {
     return null;
 }
Exemplo n.º 11
0
 /// <summary>
 /// Called on the IO thread before a resource request is loaded. The |request|
 /// object may be modified. To cancel the request return true otherwise return
 /// false.
 /// </summary>
 protected virtual bool OnBeforeResourceLoad(CefBrowser browser, CefFrame frame, CefRequest request)
 {
     return false;
 }
Exemplo n.º 12
0
 /// <summary>
 /// Called on the UI thread before browser navigation. Return true to cancel
 /// the navigation or false to allow the navigation to proceed. The |request|
 /// object cannot be modified in this callback.
 /// CefLoadHandler::OnLoadingStateChange will be called twice in all cases.
 /// If the navigation is allowed CefLoadHandler::OnLoadStart and
 /// CefLoadHandler::OnLoadEnd will be called. If the navigation is canceled
 /// CefLoadHandler::OnLoadError will be called with an |errorCode| value of
 /// ERR_ABORTED.
 /// </summary>
 protected virtual bool OnBeforeBrowse(CefBrowser browser, CefFrame frame, CefRequest request, bool isRedirect)
 {
     return false;
 }
Exemplo n.º 13
0
 /// <summary>
 /// Create a new CefRequest object.
 /// </summary>
 public static CefRequest Create()
 {
     return(CefRequest.FromNative(
                cef_request_t.create()
                ));
 }
Exemplo n.º 14
0
 /// <summary>
 /// Called before browser navigation. Return true to cancel the navigation or
 /// false to allow the navigation to proceed. The |request| object cannot be
 /// modified in this callback.
 /// </summary>
 protected virtual bool OnBeforeNavigation(CefBrowser browser, CefFrame frame, CefRequest request, CefNavigationType navigation_type, bool isRedirect)
 {
     return(false);
 }
 /// <summary>
 /// Return a new resource handler instance to handle the request or an empty
 /// reference to allow default handling of the request. |browser| and |frame|
 /// will be the browser window and frame respectively that originated the
 /// request or NULL if the request did not originate from a browser window
 /// (for example, if the request came from CefURLRequest). The |request| object
 /// passed to this method will not contain cookie data.
 /// </summary>
 protected abstract CefResourceHandler Create(CefBrowser browser, CefFrame frame, string schemeName, CefRequest request);
Exemplo n.º 16
0
 /// <summary>
 /// Begin processing the request. To handle the request return true and call
 /// CefCallback::Continue() once the response header information is available
 /// (CefCallback::Continue() can also be called from inside this method if
 /// header information is available immediately). To cancel the request return
 /// false.
 /// </summary>
 protected abstract bool ProcessRequest(CefRequest request, CefCallback callback);
 protected override bool OnBeforeNavigation(CefBrowser browser, CefFrame frame, CefRequest request, CefNavigationType navigation_type, bool isRedirect)
 {
     return base.OnBeforeNavigation(browser, frame, request, navigation_type, isRedirect);
 }
 /// <summary>
 /// Called before browser navigation. Return true to cancel the navigation or
 /// false to allow the navigation to proceed. The |request| object cannot be
 /// modified in this callback.
 /// </summary>
 protected virtual bool OnBeforeNavigation(CefBrowser browser, CefFrame frame, CefRequest request, CefNavigationType navigation_type, bool isRedirect)
 {
     return false;
 }