-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathProxyGateway.cs
39 lines (31 loc) · 1.19 KB
/
ProxyGateway.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
// The Sisk Framework source code
// Copyright (c) 2024- PROJECT PRINCIPIUM and all Sisk contributors
//
// The code below is licensed under the MIT license as
// of the date of its publication, available at
//
// File name: ProxyGateway.cs
// Repository: https://github.com/sisk-http/core
using System.Net;
namespace Sisk.Ssl;
class ProxyGateway : IDisposable {
HttpClient client;
public IPEndPoint GatewayEndpoint { get; }
public ProxyGateway ( IPEndPoint endpoint ) {
var httpHandler = new HttpClientHandler () {
AllowAutoRedirect = false,
AutomaticDecompression = DecompressionMethods.None,
ServerCertificateCustomValidationCallback = ( message, cert, chain, errors ) => {
return true;
},
};
client = new HttpClient ( httpHandler );
GatewayEndpoint = endpoint;
}
public Task<HttpResponseMessage> SendMessageAsync ( HttpRequestMessage requestMessage, CancellationToken cancellationToken = default ) {
return client.SendAsync ( requestMessage, HttpCompletionOption.ResponseHeadersRead, cancellationToken );
}
public void Dispose () {
client.Dispose ();
}
}