forked from cefsharp/CefSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUrlRequestClient.cs
More file actions
45 lines (35 loc) · 1.28 KB
/
UrlRequestClient.cs
File metadata and controls
45 lines (35 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// 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 readonly Action<IUrlRequest, byte[]> completeAction;
private readonly MemoryStream responseBody = new MemoryStream();
public UrlRequestClient(Action<IUrlRequest, byte[]> completeAction)
{
this.completeAction = completeAction;
}
bool IUrlRequestClient.GetAuthCredentials(bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback)
{
return true;
}
void IUrlRequestClient.OnDownloadData(IUrlRequest request, Stream data)
{
data.CopyTo(responseBody);
}
void IUrlRequestClient.OnDownloadProgress(IUrlRequest request, long current, long total)
{
}
void IUrlRequestClient.OnRequestComplete(IUrlRequest request)
{
this?.completeAction(request, responseBody.ToArray());
}
void IUrlRequestClient.OnUploadProgress(IUrlRequest request, long current, long total)
{
}
}
}