CompServWorkerClient.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. using static CompServ.CompServConst;
  2. using HttpMethod = System.Net.Http.HttpMethod;
  3. using HttpVersion = System.Net.HttpVersion;
  4. namespace CompServ.ClientLibrary
  5. {
  6. public class CompServWorkerClient(string server) : CompServClient(server, ApiPathWorkerRootForCheckAlive, AliveMessageWorker)
  7. {
  8. public async Task<byte[]> CompressAsync(CompressRequestModel request)
  9. {
  10. var message = request.BuildRequestMessage();
  11. var http = new HttpClient { BaseAddress = ServerUri };
  12. var r = await http.SendAsync(message);
  13. r.EnsureSuccessStatusCode();
  14. var compressedBytes = await r.Content.ReadAsByteArrayAsync();
  15. return compressedBytes;
  16. }
  17. public async Task<byte[]> DecompressAsync(DecompressRequestModel request)
  18. {
  19. var message = request.BuildRequestMessage();
  20. var http = new HttpClient { BaseAddress = ServerUri };
  21. var r = await http.SendAsync(message);
  22. r.EnsureSuccessStatusCode();
  23. var bytes = await r.Content.ReadAsByteArrayAsync();
  24. return bytes;
  25. }
  26. }
  27. }