|
@@ -2,9 +2,11 @@
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Net;
|
|
|
+using System.Reflection;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
+using Microsoft.AspNetCore.Server.HttpSys;
|
|
|
using static CompServ.CompServConst;
|
|
|
|
|
|
namespace CompServ
|
|
@@ -39,7 +41,6 @@ namespace CompServ
|
|
|
{
|
|
|
{RequestHeaderCompressLevel,model.Level.ToString()},
|
|
|
{RequestHeaderCompressThreads,model.Threads.ToString()},
|
|
|
-
|
|
|
},
|
|
|
Version = HttpVersion.Version20,
|
|
|
VersionPolicy = HttpVersionPolicy.RequestVersionExact,
|
|
@@ -51,7 +52,56 @@ namespace CompServ
|
|
|
{
|
|
|
return new HttpRequestMessage(HttpMethod.Post, ApiPathWorkerDecompress)
|
|
|
{
|
|
|
+ Version = HttpVersion.Version20,
|
|
|
+ VersionPolicy = HttpVersionPolicy.RequestVersionExact,
|
|
|
Content = new ByteArrayContent(model.DataToDecompress.Array!, model.DataToDecompress.Offset, model.DataToDecompress.Count),
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ public static HttpRequestMessage BuildWorkerRegisterRequestMessage(int port, int ratio)
|
|
|
+ {
|
|
|
+ return new HttpRequestMessage(HttpMethod.Post, ApiPathHubRegisterWorker)
|
|
|
+ {
|
|
|
+ Headers =
|
|
|
+ {
|
|
|
+ { RequestHeaderWorkerPort, port.ToString() },
|
|
|
+ { RequestHeaderWorkerRatio, ratio.ToString() }
|
|
|
+ },
|
|
|
+ Content = new ByteArrayContent(Array.Empty<byte>()),
|
|
|
+ Version = HttpVersion.Version20,
|
|
|
+ VersionPolicy = HttpVersionPolicy.RequestVersionExact,
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ public static HttpRequestMessage BuildWorkerUnRegisterRequestMessage(int port)
|
|
|
+ {
|
|
|
+ return new HttpRequestMessage(HttpMethod.Post, ApiPathHubUnRegisterWorker)
|
|
|
+ {
|
|
|
+ Headers = { { RequestHeaderWorkerPort, port.ToString() } },
|
|
|
+ Content = new ByteArrayContent(Array.Empty<byte>()),
|
|
|
+ Version = HttpVersion.Version20,
|
|
|
+ VersionPolicy = HttpVersionPolicy.RequestVersionExact,
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ public static (int? port, int? ratio) ExtractWorkerRegister(this HttpRequest request)
|
|
|
+ {
|
|
|
+ var p = int.TryParse(request.Headers[RequestHeaderWorkerPort], out var port)
|
|
|
+ ? (int?)port
|
|
|
+ : null;
|
|
|
+
|
|
|
+ var r = int.TryParse(request.Headers[RequestHeaderWorkerRatio], out var ratio)
|
|
|
+ ? (int?)ratio
|
|
|
+ : null;
|
|
|
+
|
|
|
+ return (p, r);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static HttpRequestMessage BuildClientGetWorkerRequest()
|
|
|
+ {
|
|
|
+ return new HttpRequestMessage(HttpMethod.Get, ApiPathHubGetWorker)
|
|
|
+ {
|
|
|
+ Content = new ByteArrayContent(Array.Empty<byte>()),
|
|
|
Version = HttpVersion.Version20,
|
|
|
VersionPolicy = HttpVersionPolicy.RequestVersionExact,
|
|
|
};
|