-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathG2OHttpClientHandler.cs
43 lines (38 loc) · 1.34 KB
/
G2OHttpClientHandler.cs
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
namespace G2O
{
using Owin;
using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
public class G2OHttpClientHandler : HttpClientHandler
{
private int Version;
private string EdgeIP;
private string ClientIP;
private string Nonce;
private string NonceValue;
public G2OHttpClientHandler(int version, string edgeIP, string clientIP, string nonce, string nonceValue)
{
this.Version = version;
this.EdgeIP = edgeIP;
this.ClientIP = clientIP;
this.Nonce = nonce;
this.NonceValue = nonceValue;
}
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
var signature = G2OData.CreateSignature(
version: this.Version,
edgeIP: this.EdgeIP,
clientIP: this.ClientIP,
time: DateTimeOffset.UtcNow,
uniqueId: Guid.NewGuid().ToString(),
nonce: this.Nonce,
nonceValue: this.NonceValue,
path: request.RequestUri.LocalPath);
request.SetG2OSignatureHeaders(signature);
return await base.SendAsync(request, cancellationToken);
}
}
}