/// <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);
            }
        }
        /// <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();
            }
        }
        /// <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;
        }