// Copyright © 2021 The CefSharp Authors. All rights reserved. // // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. using System.IO; namespace CefSharp { /// /// Interface that should be implemented by the CefURLRequest client. /// The methods of this class will be called on the same thread that created the request unless otherwise documented. /// public class UrlRequestClient : IUrlRequestClient { /// /// Called on the CEF IO thread when the browser needs credentials from the user. /// This method will only be called for requests initiated from the browser process. /// /// indicates whether the host is a proxy server. /// the hostname. /// the port number. /// realm /// scheme /// is a callback for authentication information /// /// Return true to continue the request and call when the authentication information is available. /// If the request has an associated browser/frame then returning false will result in a call to /// on the associated with that browser, if any. /// Otherwise, returning false will cancel the request immediately. /// bool IUrlRequestClient.GetAuthCredentials(bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback) { return GetAuthCredentials(isProxy, host, port, realm, scheme, callback); } /// /// Called on the CEF IO thread when the browser needs credentials from the user. /// This method will only be called for requests initiated from the browser process. /// /// indicates whether the host is a proxy server. /// the hostname. /// the port number. /// realm /// scheme /// is a callback for authentication information /// /// Return true to continue the request and call when the authentication information is available. /// If the request has an associated browser/frame then returning false will result in a call to /// on the associated with that browser, if any. /// Otherwise, returning false will cancel the request immediately. /// protected virtual bool GetAuthCredentials(bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback) { return false; } /// /// Called when some part of the response is read. This method will not be called if the flag is set on the request. /// /// request /// A stream containing the bytes received since the last call. Cannot be used outside the scope of this method. void IUrlRequestClient.OnDownloadData(IUrlRequest request, Stream data) { OnDownloadData(request, data); } /// /// Called when some part of the response is read. This method will not be called if the flag is set on the request. /// /// request /// A stream containing the bytes received since the last call. Cannot be used outside the scope of this method. protected virtual void OnDownloadData(IUrlRequest request, Stream data) { } /// /// Notifies the client of download progress. /// /// request /// denotes the number of bytes received up to the call /// is the expected total size of the response (or -1 if not determined). void IUrlRequestClient.OnDownloadProgress(IUrlRequest request, long current, long total) { OnDownloadProgress(request, current, total); } /// /// Notifies the client of download progress. /// /// request /// denotes the number of bytes received up to the call /// is the expected total size of the response (or -1 if not determined). protected virtual void OnDownloadProgress(IUrlRequest request, long current, long total) { } /// /// Notifies the client that the request has completed. /// Use the property to determine if the /// request was successful or not. /// /// request void IUrlRequestClient.OnRequestComplete(IUrlRequest request) { OnRequestComplete(request); } /// /// Notifies the client that the request has completed. /// Use the property to determine if the /// request was successful or not. /// /// request protected virtual void OnRequestComplete(IUrlRequest request) { } /// /// Notifies the client of upload progress. /// This method will only be called if the UR_FLAG_REPORT_UPLOAD_PROGRESS flag is set on the request. /// /// request /// denotes the number of bytes sent so far. /// is the total size of uploading data (or -1 if chunked upload is enabled). void IUrlRequestClient.OnUploadProgress(IUrlRequest request, long current, long total) { OnUploadProgress(request, current, total); } /// /// Notifies the client of upload progress. /// This method will only be called if the UR_FLAG_REPORT_UPLOAD_PROGRESS flag is set on the request. /// /// request /// denotes the number of bytes sent so far. /// is the total size of uploading data (or -1 if chunked upload is enabled). protected virtual void OnUploadProgress(IUrlRequest request, long current, long total) { } } }