From d66798b03ef69c6a3ee72fb79452fa7ffb079b41 Mon Sep 17 00:00:00 2001 From: David M Iserovich Date: Tue, 1 Oct 2019 06:11:10 -0400 Subject: [PATCH] Core - Add IURLRequest #1721 (#2881) * Core - Add IURLRequest #1721 Add IURLRequest, IURLRequestClient, and GetURLRequest to IFrame * Rename URL classes to Url, add xmldoc and licenses * Add UrlRequestClient to CefSharp.Example, more minor cleanup * Getters * Rebase tweaks * Fix filenames, remove unused * Use UnmanagedMemoryStream instead of byte array for IUrlRequestClient.OnDownloadData --- .../Wrapper/Frame.cpp | 5 + .../Wrapper/Frame.h | 2 + CefSharp.Core/CefSharp.Core.vcxproj | 4 + CefSharp.Core/CefSharp.Core.vcxproj.filters | 12 +++ CefSharp.Core/Internals/CefFrameWrapper.cpp | 13 +++ CefSharp.Core/Internals/CefFrameWrapper.h | 24 +++++ .../Internals/CefUrlRequestClientAdapter.cpp | 51 ++++++++++ .../Internals/CefUrlRequestClientAdapter.h | 95 +++++++++++++++++++ .../Internals/CefUrlRequestWrapper.cpp | 29 ++++++ .../Internals/CefUrlRequestWrapper.h | 76 +++++++++++++++ CefSharp.Example/CefSharp.Example.csproj | 1 + CefSharp.Example/UrlRequestClient.cs | 46 +++++++++ .../OffScreen/OffScreenBrowserBasicFacts.cs | 45 +++++++++ CefSharp/CefSharp.csproj | 5 + CefSharp/IFrame.cs | 23 ++++- CefSharp/IUrlRequest.cs | 33 +++++++ CefSharp/IUrlRequestClient.cs | 65 +++++++++++++ 17 files changed, 527 insertions(+), 2 deletions(-) create mode 100644 CefSharp.Core/Internals/CefUrlRequestClientAdapter.cpp create mode 100644 CefSharp.Core/Internals/CefUrlRequestClientAdapter.h create mode 100644 CefSharp.Core/Internals/CefUrlRequestWrapper.cpp create mode 100644 CefSharp.Core/Internals/CefUrlRequestWrapper.h create mode 100644 CefSharp.Example/UrlRequestClient.cs create mode 100644 CefSharp/IUrlRequest.cs create mode 100644 CefSharp/IUrlRequestClient.cs diff --git a/CefSharp.BrowserSubprocess.Core/Wrapper/Frame.cpp b/CefSharp.BrowserSubprocess.Core/Wrapper/Frame.cpp index 1c7798844..13daecbcf 100644 --- a/CefSharp.BrowserSubprocess.Core/Wrapper/Frame.cpp +++ b/CefSharp.BrowserSubprocess.Core/Wrapper/Frame.cpp @@ -290,6 +290,11 @@ IRequest^ Frame::CreateRequest(bool initializePostData) throw gcnew NotImplementedException(); } +IUrlRequest^ Frame::CreateUrlRequest(IRequest^ request, IUrlRequestClient^ client) +{ + throw gcnew NotImplementedException(); +} + bool Frame::IsDisposed::get() { return _disposed; diff --git a/CefSharp.BrowserSubprocess.Core/Wrapper/Frame.h b/CefSharp.BrowserSubprocess.Core/Wrapper/Frame.h index 52f937563..ff852d635 100644 --- a/CefSharp.BrowserSubprocess.Core/Wrapper/Frame.h +++ b/CefSharp.BrowserSubprocess.Core/Wrapper/Frame.h @@ -244,6 +244,8 @@ namespace CefSharp virtual IRequest^ CreateRequest(bool initializePostData); + virtual IUrlRequest^ CreateUrlRequest(IRequest^ request, IUrlRequestClient^ client); + virtual property bool IsDisposed { bool get(); diff --git a/CefSharp.Core/CefSharp.Core.vcxproj b/CefSharp.Core/CefSharp.Core.vcxproj index 5e6d6a829..8615f507b 100644 --- a/CefSharp.Core/CefSharp.Core.vcxproj +++ b/CefSharp.Core/CefSharp.Core.vcxproj @@ -235,6 +235,8 @@ + + @@ -270,6 +272,8 @@ + + diff --git a/CefSharp.Core/CefSharp.Core.vcxproj.filters b/CefSharp.Core/CefSharp.Core.vcxproj.filters index a88617d06..643b6d192 100644 --- a/CefSharp.Core/CefSharp.Core.vcxproj.filters +++ b/CefSharp.Core/CefSharp.Core.vcxproj.filters @@ -83,6 +83,12 @@ Source Files + + Source Files + + + Source Files + @@ -313,6 +319,12 @@ Header Files + + Header Files + + + Header Files + diff --git a/CefSharp.Core/Internals/CefFrameWrapper.cpp b/CefSharp.Core/Internals/CefFrameWrapper.cpp index 14b742e81..bbc481957 100644 --- a/CefSharp.Core/Internals/CefFrameWrapper.cpp +++ b/CefSharp.Core/Internals/CefFrameWrapper.cpp @@ -12,6 +12,8 @@ #include "Internals\ClientAdapter.h" #include "Internals\Serialization\Primitives.h" #include "Internals\Messaging\Messages.h" +#include "Internals\CefURLRequestWrapper.h" +#include "Internals\CefURLRequestClientAdapter.h" using namespace CefSharp::Internals::Messaging; using namespace CefSharp::Internals::Serialization; @@ -407,6 +409,17 @@ IRequest^ CefFrameWrapper::CreateRequest(bool initializePostData) return gcnew CefRequestWrapper(request); } +IUrlRequest^ CefFrameWrapper::CreateUrlRequest(IRequest^ request, IUrlRequestClient^ client) +{ + ThrowIfDisposed(); + + auto urlRequest = _frame->CreateURLRequest( + (CefRequestWrapper^)request, + new CefUrlRequestClientAdapter(client)); + + return gcnew CefUrlRequestWrapper(urlRequest); +} + void CefFrameWrapper::ThrowIfFrameInvalid() { if (_frame->IsValid() == false) diff --git a/CefSharp.Core/Internals/CefFrameWrapper.h b/CefSharp.Core/Internals/CefFrameWrapper.h index b79454d82..90f2cc0bd 100644 --- a/CefSharp.Core/Internals/CefFrameWrapper.h +++ b/CefSharp.Core/Internals/CefFrameWrapper.h @@ -255,6 +255,30 @@ namespace CefSharp virtual IRequest^ CreateRequest(bool initializePostData); + /// + // Create a new URL request that will be treated as originating from this + // frame and the associated browser. This request may be intercepted by the + // client via CefResourceRequestHandler or CefSchemeHandlerFactory. Use + // CefURLRequest::Create instead if you do not want the request to have this + // association, in which case it may be handled differently (see documentation + // on that method). Requests may originate from both the browser process and + // the render process. + // + // For requests originating from the browser process: + // - POST data may only contain a single element of type PDE_TYPE_FILE or + // PDE_TYPE_BYTES. + // For requests originating from the render process: + // - POST data may only contain a single element of type PDE_TYPE_BYTES. + // - 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. + /// + /*--cef()--*/ + virtual IUrlRequest^ CreateUrlRequest(IRequest^ request, IUrlRequestClient^ client); + void ThrowIfFrameInvalid(); }; } diff --git a/CefSharp.Core/Internals/CefUrlRequestClientAdapter.cpp b/CefSharp.Core/Internals/CefUrlRequestClientAdapter.cpp new file mode 100644 index 000000000..1757379fc --- /dev/null +++ b/CefSharp.Core/Internals/CefUrlRequestClientAdapter.cpp @@ -0,0 +1,51 @@ +// Copyright © 2019 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. + +#include "Stdafx.h" +#include "CefUrlRequestClientAdapter.h" +#include "CefUrlRequestWrapper.h" +#include "CefAuthCallbackWrapper.h" + +using namespace System::IO; + +void CefUrlRequestClientAdapter::OnRequestComplete(CefRefPtr request) +{ + _client->OnRequestComplete(gcnew CefUrlRequestWrapper(request)); +} + +void CefUrlRequestClientAdapter::OnUploadProgress(CefRefPtr request, int64 current, int64 total) +{ + _client->OnUploadProgress(gcnew CefUrlRequestWrapper(request), current, total); +} + +void CefUrlRequestClientAdapter::OnDownloadProgress(CefRefPtr request, int64 current, int64 total) +{ + _client->OnDownloadProgress(gcnew CefUrlRequestWrapper(request), current, total); +} + +void CefUrlRequestClientAdapter::OnDownloadData(CefRefPtr request, const void* data, size_t data_length) +{ + UnmanagedMemoryStream readStream((Byte*)data, (Int64)data_length, (Int64)data_length, FileAccess::Read); + _client->OnDownloadData( + gcnew CefUrlRequestWrapper(request), + %readStream + ); +} + +bool CefUrlRequestClientAdapter::GetAuthCredentials(bool isProxy, + const CefString& host, + int port, + const CefString& realm, + const CefString& scheme, + CefRefPtr callback) +{ + return _client->GetAuthCredentials( + isProxy, + StringUtils::ToClr(host), + port, + StringUtils::ToClr(realm), + StringUtils::ToClr(scheme), + gcnew CefAuthCallbackWrapper(callback)); +} + diff --git a/CefSharp.Core/Internals/CefUrlRequestClientAdapter.h b/CefSharp.Core/Internals/CefUrlRequestClientAdapter.h new file mode 100644 index 000000000..bc95bf02c --- /dev/null +++ b/CefSharp.Core/Internals/CefUrlRequestClientAdapter.h @@ -0,0 +1,95 @@ +// Copyright © 2019 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. + +#pragma once + +#include "Stdafx.h" +#include "Include\cef_urlrequest.h" + +namespace CefSharp +{ + namespace Internals + { + + /// 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 CefUrlRequestClientAdapter : public CefURLRequestClient + { + private: + gcroot _client; + + public: + CefUrlRequestClientAdapter(IUrlRequestClient^ client) + { + _client = client; + } + + ~CefUrlRequestClientAdapter() + { + delete _client; + _client = nullptr; + } + + // Notifies the client that the request has completed. Use the + // CefURLRequest::GetRequestStatus method to determine if the request was + // successful or not. + /// + /*--cef()--*/ + virtual void OnRequestComplete(CefRefPtr request) OVERRIDE; + + /// + // Notifies the client of upload progress. |current| denotes the number of + // bytes sent so far and |total| is the total size of uploading data (or -1 if + // chunked upload is enabled). This method will only be called if the + // UR_FLAG_REPORT_UPLOAD_PROGRESS flag is set on the request. + /// + /*--cef()--*/ + virtual void OnUploadProgress(CefRefPtr request, + int64 current, + int64 total) OVERRIDE; + + ///ref + // Notifies the client of download progress. |current| denotes the number of + // bytes received up to the call and |total| is the expected total size of the + // response (or -1 if not determined). + /// + /*--cef()--*/ + virtual void OnDownloadProgress(CefRefPtr request, + int64 current, + int64 total) OVERRIDE; + + /// + // Called when some part of the response is read. |data| contains the current + // bytes received since the last call. This method will not be called if the + // UR_FLAG_NO_DOWNLOAD_DATA flag is set on the request. + /// + /*--cef()--*/ + virtual void OnDownloadData(CefRefPtr request, + const void* data, + size_t data_length) OVERRIDE; + + /// + // Called on the IO thread when the browser needs credentials from the user. + // |isProxy| indicates whether the host is a proxy server. |host| contains the + // hostname and |port| contains the port number. Return true to continue the + // request and call CefAuthCallback::Continue() when the authentication + // information is available. If the request has an associated browser/frame + // then returning false will result in a call to GetAuthCredentials on the + // CefRequestHandler associated with that browser, if any. Otherwise, + // returning false will cancel the request immediately. This method will only + // be called for requests initiated from the browser process. + /// + /*--cef(optional_param=realm)--*/ + virtual bool GetAuthCredentials(bool isProxy, + const CefString& host, + int port, + const CefString& realm, + const CefString& scheme, + CefRefPtr callback) OVERRIDE; + + IMPLEMENT_REFCOUNTING(CefUrlRequestClientAdapter); + }; + } +} diff --git a/CefSharp.Core/Internals/CefUrlRequestWrapper.cpp b/CefSharp.Core/Internals/CefUrlRequestWrapper.cpp new file mode 100644 index 000000000..c9fe4c510 --- /dev/null +++ b/CefSharp.Core/Internals/CefUrlRequestWrapper.cpp @@ -0,0 +1,29 @@ +// Copyright © 2019 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. + +#include "Stdafx.h" +#include "CefUrlRequestWrapper.h" +#include "CefResponseWrapper.h" + +bool CefUrlRequestWrapper::ResponseWasCached::get() +{ + ThrowIfDisposed(); + + return _urlRequest->ResponseWasCached(); +} + +IResponse^ CefUrlRequestWrapper::Response::get() +{ + ThrowIfDisposed(); + + return gcnew CefResponseWrapper(_urlRequest->GetResponse()); +} + +UrlRequestStatus CefUrlRequestWrapper::RequestStatus::get() +{ + ThrowIfDisposed(); + + return (UrlRequestStatus)_urlRequest->GetRequestStatus(); +} + diff --git a/CefSharp.Core/Internals/CefUrlRequestWrapper.h b/CefSharp.Core/Internals/CefUrlRequestWrapper.h new file mode 100644 index 000000000..6bdf2161f --- /dev/null +++ b/CefSharp.Core/Internals/CefUrlRequestWrapper.h @@ -0,0 +1,76 @@ +// Copyright © 2019 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. + +#pragma once + +#include "Stdafx.h" + +#include "include\cef_urlrequest.h" +#include "CefWrapper.h" + +namespace CefSharp +{ + namespace Internals + { + /// + // Class used to make a URL request. URL requests are not associated with + // a browser instance so no CefClient callbacks will be executed. + // URL requests can be created on any valid CEF thread in either the browser + // or render process. Once created the methods of the URL request object must + // be accessed on the same thread that created it. + /// + /*--cef(source=library)--*/ + ref class CefUrlRequestWrapper : public IUrlRequest, public CefWrapper + { + private: + MCefRefPtr _urlRequest; + internal: + CefUrlRequestWrapper::CefUrlRequestWrapper(CefRefPtr &urlRequest) + : _urlRequest(urlRequest) + { + } + + !CefUrlRequestWrapper() + { + _urlRequest = NULL; + } + + ~CefUrlRequestWrapper() + { + this->!CefUrlRequestWrapper(); + } + + public: + /// + // Returns true if the response body was served from the cache. This includes + // responses for which revalidation was required. + /// + /*--cef()--*/ + virtual property bool ResponseWasCached + { + bool get(); + } + + /// + // 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. + /// + /*--cef()--*/ + virtual property IResponse^ Response + { + IResponse^ get(); + } + + /// + // Returns the request status. + /// + /*--cef(default_retval=UR_UNKNOWN)--*/ + virtual property UrlRequestStatus RequestStatus + { + UrlRequestStatus get(); + } + }; + } +} diff --git a/CefSharp.Example/CefSharp.Example.csproj b/CefSharp.Example/CefSharp.Example.csproj index 80677a2e6..ff4b2cb45 100644 --- a/CefSharp.Example/CefSharp.Example.csproj +++ b/CefSharp.Example/CefSharp.Example.csproj @@ -127,6 +127,7 @@ + diff --git a/CefSharp.Example/UrlRequestClient.cs b/CefSharp.Example/UrlRequestClient.cs new file mode 100644 index 000000000..679b69ef2 --- /dev/null +++ b/CefSharp.Example/UrlRequestClient.cs @@ -0,0 +1,46 @@ +// Copyright © 2019 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; +using System.IO; + +namespace CefSharp.Example +{ + + public class UrlRequestClient : IUrlRequestClient + { + private Action CompleteAction; + private MemoryStream ResponseBody = new MemoryStream(); + + public UrlRequestClient(Action completeAction) + { + CompleteAction = completeAction; + } + public bool GetAuthCredentials(bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback) + { + return true; + } + + public void OnDownloadData(IUrlRequest request, Stream data) + { + data.CopyTo(ResponseBody); + } + + public void OnDownloadProgress(IUrlRequest request, long current, long total) + { + return; + } + + public void OnRequestComplete(IUrlRequest request) + { + + CompleteAction(request, ResponseBody.ToArray()); + } + + public void OnUploadProgress(IUrlRequest request, long current, long total) + { + return; + } + } +} diff --git a/CefSharp.Test/OffScreen/OffScreenBrowserBasicFacts.cs b/CefSharp.Test/OffScreen/OffScreenBrowserBasicFacts.cs index e3393027d..4c94b62e8 100644 --- a/CefSharp.Test/OffScreen/OffScreenBrowserBasicFacts.cs +++ b/CefSharp.Test/OffScreen/OffScreenBrowserBasicFacts.cs @@ -2,10 +2,14 @@ // // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +using System; +using System.IO; +using System.Threading; using CefSharp.OffScreen; using System.Threading.Tasks; using Xunit; using Xunit.Abstractions; +using CefSharp.Example; namespace CefSharp.Test.OffScreen { @@ -127,5 +131,46 @@ namespace CefSharp.Test.OffScreen } } + + [Fact] + public async Task CanMakeUrlRequest() + { + using (var browser = new ChromiumWebBrowser("https://code.jquery.com/jquery-3.4.1.min.js")) + { + await browser.LoadPageAsync(); + + var mainFrame = browser.GetMainFrame(); + Assert.True(mainFrame.IsValid); + + + IUrlRequest urlRequest = null; + + var t = new TaskCompletionSource(); + var wasCached = false; + var requestClient = new UrlRequestClient( + (IUrlRequest request, byte[] responseBody) => + { + wasCached = request.ResponseWasCached; + t.TrySetResult(System.Text.Encoding.UTF8.GetString(responseBody)); + } + ); + + //Make the request on the CEF UI Thread + await Cef.UIThreadTaskFactory.StartNew(delegate + { + var request = mainFrame.CreateRequest(false); + + request.Method = "GET"; + request.Url = "https://code.jquery.com/jquery-3.4.1.min.js"; + urlRequest = mainFrame.CreateUrlRequest(request, requestClient); + }); + + var stringResult = await t.Task; + + Assert.True(!string.IsNullOrEmpty(stringResult)); + Assert.True(wasCached); + } + } + } } diff --git a/CefSharp/CefSharp.csproj b/CefSharp/CefSharp.csproj index 5cde03fb7..69458b0b4 100644 --- a/CefSharp/CefSharp.csproj +++ b/CefSharp/CefSharp.csproj @@ -102,6 +102,11 @@ + + + + + diff --git a/CefSharp/IFrame.cs b/CefSharp/IFrame.cs index b666a4c27..7fe973e02 100644 --- a/CefSharp/IFrame.cs +++ b/CefSharp/IFrame.cs @@ -71,7 +71,7 @@ namespace CefSharp /// Retrieve this frame's HTML source as a string sent to the specified visitor. /// Use the method for a Task based async wrapper /// - /// visitor will recieve string values asynchronously + /// visitor will receive string values asynchronously void GetSource(IStringVisitor visitor); /// @@ -86,7 +86,7 @@ namespace CefSharp /// Retrieve this frame's display text as a string sent to the specified visitor. /// Use the method for a Task based async wrapper /// - /// visitor will recieve string values asynchronously + /// visitor will receive string values asynchronously void GetText(IStringVisitor visitor); /// @@ -182,5 +182,24 @@ namespace CefSharp /// Initialize the PostData object when creating this request /// A new instance of the request IRequest CreateRequest(bool initializePostData = true); + + /// + /// Create a new URL request that will be treated as originating from this frame + /// and the associated browser. This request may be intercepted by the client via + /// or . + /// Use IUrlRequest.Create instead if you do not want the request to have + /// this association, in which case it may be handled differently (see documentation on that method). + /// + /// Requests may originate from both the browser process and the render process. + /// For requests originating from the browser process: - POST data may only contain a single element + /// of type PDE_TYPE_FILE or PDE_TYPE_BYTES. + /// For requests originating from the render process: - POST data may only contain a single element of type PDE_TYPE_BYTES. + /// - 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. + /// + IUrlRequest CreateUrlRequest(IRequest request, IUrlRequestClient client); } } diff --git a/CefSharp/IUrlRequest.cs b/CefSharp/IUrlRequest.cs new file mode 100644 index 000000000..fc326fa10 --- /dev/null +++ b/CefSharp/IUrlRequest.cs @@ -0,0 +1,33 @@ +// Copyright © 2019 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; + +namespace CefSharp +{ + /// + /// Class used to make a URL request. URL requests are not associated with + /// a browser instance so no CefClient callbacks will be executed. + /// URL requests can be created on any valid CEF thread in either the browser + /// or render process. Once created the methods of the URL request object must + /// be accessed on the same thread that created it. + /// + public interface IUrlRequest : IDisposable + { + /// + /// True if the response was served from the cache. + /// + bool ResponseWasCached { get; } + + /// + /// The response, or null if no response information is available + /// + IResponse Response { get; } + + /// + /// The request status. + /// + UrlRequestStatus RequestStatus { get; } + } +} diff --git a/CefSharp/IUrlRequestClient.cs b/CefSharp/IUrlRequestClient.cs new file mode 100644 index 000000000..f158e9666 --- /dev/null +++ b/CefSharp/IUrlRequestClient.cs @@ -0,0 +1,65 @@ +// Copyright © 2019 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 interface IUrlRequestClient + { + /// + /// Called on the 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. + /// + /// + /// is a callback for authentication information + /// + /// Return true to continue the request and call IAuthCallback.Continue() when the authentication information is available. + /// If the request has an associated browser/frame then returning false will result in a call to GetAuthCredentials + /// on the IRequestHandler associated with that browser, if any. + /// Otherwise, returning false will cancel the request immediately. + /// + + bool GetAuthCredentials(bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback); + /// + /// Called when some part of the response is read. This method will not be called if the UR_FLAG_NO_DOWNLOAD_DATA flag is set on the request. + /// + /// + /// Contains the current bytes received since the last call. + void OnDownloadData(IUrlRequest request, Stream data); + + /// + /// Notifies the client of download progress. + /// + /// + /// denotes the number of bytes received up to the call + /// is the expected total size of the response (or -1 if not determined). + void OnDownloadProgress(IUrlRequest request, long current, long total); + + /// + /// Notifies the client that the request has completed. Use the + /// IURLRequest.GetRequestStatus method to determine if the request was + /// successful or not. + /// + /// + 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. + /// + /// + /// denotes the number of bytes sent so far. + /// is the total size of uploading data (or -1 if chunked upload is enabled). + void OnUploadProgress(IUrlRequest request, long current, long total); + } +}