Exemple #1
0
        /// <summary>
        /// Called on the IO thread before a resource is loaded.  To allow the
        /// resource to load normally return false. To redirect the resource to a
        /// new url populate the |redirectUrl| value and return false.  To
        /// specify data for the resource return a CefStream object in
        /// |resourceStream|, use the |response| object to set mime type, HTTP
        /// status code and optional header values, and return false. To cancel
        /// loading of the resource return true. Any modifications to |request|
        /// will be observed.  If the URL in |request| is changed and
        /// |redirectUrl| is also set, the URL in |request| will be used.
        /// </summary>
        private int on_before_resource_load(cef_request_handler_t *self, cef_browser_t *browser, cef_request_t *request, cef_string_t *redirectUrl, cef_stream_reader_t **resourceStream, cef_response_t *response, int loadFlags)
        {
            ThrowIfObjectDisposed();

            var             m_browser = CefBrowser.From(browser);
            var             m_request = CefRequest.From(request);
            string          m_redirectUrl;
            CefStreamReader m_resourceStream;
            var             m_response = CefResponse.From(response);

            var handled = this.OnBeforeResourceLoad(m_browser, m_request, out m_redirectUrl, out m_resourceStream, m_response, loadFlags);

            if (!handled)
            {
                if (!string.IsNullOrEmpty(m_redirectUrl))
                {
                    cef_string_t.Copy(m_redirectUrl, redirectUrl);
                }

                if (m_resourceStream != null)
                {
                    *resourceStream = m_resourceStream.GetNativePointerAndAddRef();
                }
            }

            return(handled ? 1 : 0);
        }
Exemple #2
0
        /// <summary>
        /// Notifies the client of the response data.
        /// </summary>
        private void on_headers_received(cef_web_urlrequest_client_t *self, cef_web_urlrequest_t *requester, cef_response_t *response)
        {
            ThrowIfObjectDisposed();

            var m_requester = CefWebUrlRequest.From(requester);
            var m_response  = CefResponse.From(response);

            this.OnHeadersReceived(m_requester, m_response);
        }
Exemple #3
0
        /// <summary>
        /// Notifies the client that the request has been redirected and
        /// provides a chance to change the request parameters.
        /// </summary>
        private void on_redirect(cef_web_urlrequest_client_t *self, cef_web_urlrequest_t *requester, cef_request_t *request, cef_response_t *response)
        {
            ThrowIfObjectDisposed();

            var m_requester = CefWebUrlRequest.From(requester);
            var m_request   = CefRequest.From(request);
            var m_response  = CefResponse.From(response);

            this.OnRedirect(m_requester, m_request, m_response);
        }
        protected override void GetResponseHeaders(CefResponse response, out long responseLength, ref string redirectUrl)
        {
            responseLength = this.responseLength;

            if (responseLength != -1)
            {
                var headers = new CefStringMultiMap();
                headers.Append("Content-Length", responseLength.ToString());
                response.SetHeaderMap(headers);
            }

            response.SetStatus(this.status);
            response.SetStatusText(this.statusText);
            response.SetMimeType(this.mimeType);
        }
Exemple #5
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>
        private void get_response_headers(cef_scheme_handler_t *self, cef_response_t *response, long *response_length, cef_string_t *redirectUrl)
        {
            ThrowIfObjectDisposed();

            var    mResponse = CefResponse.From(response);
            long   mResponseLength;
            string mRedirectUrl = null;

            this.GetResponseHeaders(mResponse, out mResponseLength, ref mRedirectUrl);

            *response_length = mResponseLength;
            if (mRedirectUrl != null)
            {
                cef_string_t.Copy(mRedirectUrl, redirectUrl);
            }
        }
Exemple #6
0
        /// <summary>
        /// Called on the UI thread after a response to the resource request is
        /// received. Set |filter| if response content needs to be monitored
        /// and/or modified as it arrives.
        /// </summary>
        private void on_resource_response(cef_request_handler_t *self, cef_browser_t *browser, /*const*/ cef_string_t *url, cef_response_t *response, cef_content_filter_t **filter)
        {
            ThrowIfObjectDisposed();

            var m_browser  = CefBrowser.From(browser);
            var m_url      = cef_string_t.ToString(url);
            var m_response = CefResponse.From(response);
            CefContentFilter m_filter;

            this.OnResourceResponse(m_browser, m_url, m_response, out m_filter);

            if (m_filter != null)
            {
                *filter = m_filter.GetNativePointerAndAddRef();
            }
        }
Exemple #7
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, ref string redirectUrl);
Exemple #8
0
 /// <summary>
 /// Notifies the client of the response data.
 /// </summary>
 protected virtual void OnHeadersReceived(CefWebUrlRequest requester, CefResponse response)
 {
 }
Exemple #9
0
 /// <summary>
 /// Notifies the client that the request has been redirected and provides a chance to change the request parameters.
 /// </summary>
 protected virtual void OnRedirect(CefWebUrlRequest requester, CefRequest request, CefResponse response)
 {
 }
Exemple #10
0
 /// <summary>
 /// Called on the UI thread after a response to the resource request is received.
 /// Set |filter| if response content needs to be monitored and/or modified as it arrives.
 /// </summary>
 protected virtual void OnResourceResponse(CefBrowser browser, string url, CefResponse response, out CefContentFilter filter)
 {
     filter = null;
 }
Exemple #11
0
 /// <summary>
 /// Called on the IO thread before a resource is loaded.
 /// To allow the resource to load normally return false.
 /// To redirect the resource to a new url populate the |redirectUrl| value and return false.
 /// To specify data for the resource return a CefStream object in |resourceStream|,
 /// use the |response| object to set mime type, HTTP status code and optional header values, and return false.
 /// To cancel loading of the resource return true.
 /// Any modifications to |request| will be observed.
 /// If the URL in |request| is changed and |redirectUrl| is also set, the URL in |request| will be used.
 /// </summary>
 protected virtual bool OnBeforeResourceLoad(CefBrowser browser, CefRequest request, out string redirectUrl, out CefStreamReader resourceStream, CefResponse response, int loadFlags)
 {
     redirectUrl    = null;
     resourceStream = null;
     return(false);
 }
 /// <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, ref string redirectUrl);
 /// <summary>
 /// Called on the IO thread before a resource is loaded.
 /// To allow the resource to load normally return false.
 /// To redirect the resource to a new url populate the |redirectUrl| value and return false.
 /// To specify data for the resource return a CefStream object in |resourceStream|,
 /// use the |response| object to set mime type, HTTP status code and optional header values, and return false.
 /// To cancel loading of the resource return true.
 /// Any modifications to |request| will be observed.
 /// If the URL in |request| is changed and |redirectUrl| is also set, the URL in |request| will be used.
 /// </summary>
 protected virtual bool OnBeforeResourceLoad(CefBrowser browser, CefRequest request, out string redirectUrl, out CefStreamReader resourceStream, CefResponse response, int loadFlags)
 {
     redirectUrl = null;
     resourceStream = null;
     return false;
 }
 /// <summary>
 /// Called on the UI thread after a response to the resource request is received.
 /// Set |filter| if response content needs to be monitored and/or modified as it arrives.
 /// </summary>
 protected virtual void OnResourceResponse(CefBrowser browser, string url, CefResponse response, out CefContentFilter filter)
 {
     filter = null;
 }