protected override void GetResponseHeaders(CefResponse response, out long responseLength, out string redirectUrl)
        {
            if (response == null)
            {
                responseLength = -1;
                redirectUrl = null;
                return;
            }

            String extension = Path.GetExtension(uri.LocalPath);
            if (extension.Length > 1 && extension.StartsWith(".")) {
                extension = extension.Substring(1);
            }

            String mimeType;

            if (!MimeTypeManager.MimeTypes.TryGetValue(extension, out mimeType))
            {
                mimeType = "text/html";
            }

            response.Status = 200;
            response.MimeType = mimeType;
            response.StatusText = "OK";
            responseLength = length;
            redirectUrl = null;  // no-redirect
        }
        protected override void GetResponseHeaders(CefResponse response, out long responseLength, out string redirectUrl)
        {
            if (response == null)
            {
                responseLength = -1;
                redirectUrl = null;
                return;
            }

            string extension = Path.GetExtension(uri.LocalPath);
            if (extension.Length > 1 && extension.StartsWith("."))
            {
                extension = extension.Substring(1);
            }

            string mimeType;

            if (!MimeTypeManager.MimeTypes.TryGetValue(extension, out mimeType))
            {
                mimeType = "text/html";
            }

            API.Instance.Log("AssetSchemeHandler::GetResponseHeadlers File {0} mapped with mime type {1}", resolvedPath, mimeType);

            response.Status = 200;
            response.MimeType = mimeType;
            response.StatusText = "OK";
            responseLength = length;
            redirectUrl = null;  // no-redirect
        }
Exemplo n.º 3
0
        private void on_resource_load_complete(cef_request_handler_t *self, cef_browser_t *browser, cef_frame_t *frame, cef_request_t *request, cef_response_t *response, CefUrlRequestStatus status, long received_content_length)
        {
            CheckSelf(self);

            var mBrowser  = CefBrowser.FromNative(browser);
            var mFrame    = CefFrame.FromNative(frame);
            var mRequest  = CefRequest.FromNative(request);
            var mResponse = CefResponse.FromNative(response);

            OnResourceLoadComplete(mBrowser, mFrame, mRequest, mResponse, status, received_content_length);
        }
Exemplo n.º 4
0
        private int on_resource_response(cef_request_handler_t *self, cef_browser_t *browser, cef_frame_t *frame, cef_request_t *request, cef_response_t *response)
        {
            CheckSelf(self);

            var m_browser  = CefBrowser.FromNative(browser);
            var m_frame    = CefFrame.FromNative(frame);
            var m_request  = CefRequest.FromNative(request);
            var m_response = CefResponse.FromNative(response);

            var m_result = OnResourceResponse(m_browser, m_frame, m_request, m_response);

            return(m_result ? 1 : 0);
        }
Exemplo n.º 5
0
        private int can_save_cookie(cef_cookie_access_filter_t *self, cef_browser_t *browser, cef_frame_t *frame, cef_request_t *request, cef_response_t *response, cef_cookie_t *cookie)
        {
            CheckSelf(self);

            var m_browser  = CefBrowser.FromNativeOrNull(browser);
            var m_frame    = CefFrame.FromNativeOrNull(frame);
            var m_request  = CefRequest.FromNative(request);
            var m_response = CefResponse.FromNative(response);
            var m_cookie   = CefCookie.FromNative(cookie);

            var m_result = CanSaveCookie(m_browser, m_frame, m_request, m_response, m_cookie);

            return(m_result ? 1 : 0);
        }
Exemplo n.º 6
0
        private void get_response_headers(cef_resource_handler_t *self, cef_response_t *response, long *response_length, cef_string_t *redirectUrl)
        {
            CheckSelf(self);

            var    m_response = CefResponse.FromNative(response);
            long   m_responseLength;
            string m_redirectUrl;

            GetResponseHeaders(m_response, out m_responseLength, out m_redirectUrl);

            *response_length = m_responseLength;

            if (!string.IsNullOrEmpty(m_redirectUrl))
            {
                cef_string_t.Copy(m_redirectUrl, redirectUrl);
            }
        }
Exemplo n.º 7
0
        private cef_response_filter_t *get_resource_response_filter(cef_request_handler_t *self, cef_browser_t *browser, cef_frame_t *frame, cef_request_t *request, cef_response_t *response)
        {
            CheckSelf(self);

            var mBrowser  = CefBrowser.FromNative(browser);
            var mFrame    = CefFrame.FromNative(frame);
            var mRequest  = CefRequest.FromNative(request);
            var mResponse = CefResponse.FromNative(response);

            var result = GetResourceResponseFilter(mBrowser, mFrame, mRequest, mResponse);

            if (result != null)
            {
                return(result.ToNative());
            }

            return(null);
        }
Exemplo n.º 8
0
        private void on_resource_redirect(cef_request_handler_t *self, cef_browser_t *browser, cef_frame_t *frame, cef_request_t *request, cef_response_t *response, cef_string_t *new_url)
        {
            CheckSelf(self);

            var m_browser  = CefBrowser.FromNative(browser);
            var m_frame    = CefFrame.FromNative(frame);
            var m_request  = CefRequest.FromNative(request);
            var m_response = CefResponse.FromNative(response);
            var m_newUrl   = cef_string_t.ToString(new_url);

            var o_newUrl = m_newUrl;

            OnResourceRedirect(m_browser, m_frame, m_request, m_response, ref m_newUrl);

            if ((object)m_newUrl != (object)o_newUrl)
            {
                cef_string_t.Copy(m_newUrl, new_url);
            }
        }
Exemplo n.º 9
0
 /// <summary>
 /// Called on the IO thread to optionally filter resource response content.
 /// |request| and |response| represent the request and response respectively
 /// and cannot be modified in this callback.
 /// </summary>
 protected virtual CefResponseFilter GetResourceResponseFilter(CefBrowser browser, CefFrame frame, CefRequest request, CefResponse response)
 {
     return(null);
 }
Exemplo n.º 10
0
 /// <summary>
 /// Called on the IO thread when a resource response is received. To allow the
 /// resource to load normally return false. To redirect or retry the resource
 /// modify |request| (url, headers or post body) and return true. The
 /// |response| object cannot be modified in this callback.
 /// </summary>
 protected virtual bool OnResourceResponse(CefBrowser browser, CefFrame frame, CefRequest request, CefResponse response)
 {
     return(false);
 }
Exemplo n.º 11
0
 /// <summary>
 /// Called on the IO thread when a resource load is redirected. The |request|
 /// parameter will contain the old URL and other request-related information.
 /// The |response| parameter will contain the response that resulted in the
 /// redirect. The |new_url| parameter will contain the new URL and can be
 /// changed if desired. The |request| object cannot be modified in this
 /// callback.
 /// </summary>
 protected virtual void OnResourceRedirect(CefBrowser browser, CefFrame frame, CefRequest request, CefResponse response, ref string newUrl)
 {
 }
Exemplo n.º 12
0
 /// <summary>
 /// Retrieve response header information. If the response length is not known
 /// set |response_length| to -1 and ReadResponse() will be called until it
 /// returns false. If the response length is known set |response_length|
 /// to a positive value and ReadResponse() will be called until it returns
 /// false or the specified number of bytes have been read. Use the |response|
 /// object to set the mime type, http status code and other optional header
 /// values. To redirect the request to a new URL set |redirectUrl| to the new
 /// URL.
 /// </summary>
 protected abstract void GetResponseHeaders(CefResponse response, out long responseLength, out string redirectUrl);
Exemplo n.º 13
0
 /// <summary>
 /// Retrieve response header information. If the response length is not known
 /// set |response_length| to -1 and ReadResponse() will be called until it
 /// returns false. If the response length is known set |response_length|
 /// to a positive value and ReadResponse() will be called until it returns
 /// false or the specified number of bytes have been read. Use the |response|
 /// object to set the mime type, http status code and other optional header
 /// values. To redirect the request to a new URL set |redirectUrl| to the new
 /// URL.
 /// </summary>
 protected abstract void GetResponseHeaders(CefResponse response, out long responseLength, out string redirectUrl);
Exemplo n.º 14
0
 /// <summary>
 /// Called on the IO thread after a resource response is received. The
 /// |browser| and |frame| values represent the source of the request, and may
 /// be NULL for requests originating from service workers or CefURLRequest.
 /// |request| cannot be modified in this callback. Return true if the specified
 /// cookie returned with the response can be saved or false otherwise.
 /// </summary>
 protected abstract bool CanSaveCookie(CefBrowser browser, CefFrame frame, CefRequest request, CefResponse response, CefCookie cookie);
Exemplo n.º 15
0
 /// <summary>
 /// Create a new CefResponse object.
 /// </summary>
 public static CefResponse Create()
 {
     return(CefResponse.FromNative(
                cef_response_t.create()
                ));
 }
Exemplo n.º 16
0
 /// <summary>
 /// Called on the IO thread when a resource load has completed. |request| and
 /// |response| represent the request and response respectively and cannot be
 /// modified in this callback. |status| indicates the load completion status.
 /// |received_content_length| is the number of response bytes actually read.
 /// </summary>
 protected virtual void OnResourceLoadComplete(CefBrowser browser, CefFrame frame, CefRequest request, CefResponse response, CefUrlRequestStatus status, long receivedContentLength)
 {
 }
Exemplo n.º 17
0
 /// <summary>
 /// Returns the response, or NULL if no response information is available.
 /// Response information will only be available after the upload has completed.
 /// The returned object is read-only and should not be modified.
 /// </summary>
 public CefResponse GetResponse()
 {
     return(CefResponse.FromNativeOrNull(
                cef_urlrequest_t.get_response(_self)
                ));
 }
Exemplo n.º 18
0
 protected override void GetResponseHeaders(CefResponse response, out long responseLength, out string redirectUrl)
 {
     throw new NotImplementedException();
 }