2019-10-01 06:11:10 -04:00
|
|
|
// 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
|
|
|
|
|
{
|
2019-10-01 20:44:46 +10:00
|
|
|
private readonly Action<IUrlRequest, byte[]> completeAction;
|
|
|
|
|
private readonly MemoryStream responseBody = new MemoryStream();
|
2019-10-01 06:11:10 -04:00
|
|
|
|
|
|
|
|
public UrlRequestClient(Action<IUrlRequest, byte[]> completeAction)
|
|
|
|
|
{
|
2019-10-01 20:44:46 +10:00
|
|
|
this.completeAction = completeAction;
|
2019-10-01 06:11:10 -04:00
|
|
|
}
|
2019-10-01 20:44:46 +10:00
|
|
|
|
|
|
|
|
bool IUrlRequestClient.GetAuthCredentials(bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback)
|
2019-10-01 06:11:10 -04:00
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-01 20:44:46 +10:00
|
|
|
void IUrlRequestClient.OnDownloadData(IUrlRequest request, Stream data)
|
2019-10-01 06:11:10 -04:00
|
|
|
{
|
2019-10-01 20:44:46 +10:00
|
|
|
data.CopyTo(responseBody);
|
2019-10-01 06:11:10 -04:00
|
|
|
}
|
|
|
|
|
|
2019-10-01 20:44:46 +10:00
|
|
|
void IUrlRequestClient.OnDownloadProgress(IUrlRequest request, long current, long total)
|
2019-10-01 06:11:10 -04:00
|
|
|
{
|
2019-10-01 20:44:46 +10:00
|
|
|
|
2019-10-01 06:11:10 -04:00
|
|
|
}
|
|
|
|
|
|
2019-10-01 20:44:46 +10:00
|
|
|
void IUrlRequestClient.OnRequestComplete(IUrlRequest request)
|
2019-10-01 06:11:10 -04:00
|
|
|
{
|
2019-10-01 20:44:46 +10:00
|
|
|
this?.completeAction(request, responseBody.ToArray());
|
2019-10-01 06:11:10 -04:00
|
|
|
}
|
|
|
|
|
|
2019-10-01 20:44:46 +10:00
|
|
|
void IUrlRequestClient.OnUploadProgress(IUrlRequest request, long current, long total)
|
2019-10-01 06:11:10 -04:00
|
|
|
{
|
2019-10-01 20:44:46 +10:00
|
|
|
|
2019-10-01 06:11:10 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|