Did some tests to see how bad HttpClient is. Timings would be inconsistent but memory is something what can be tested:
HttpClient:
TotalAllocatedMemory 99,64 Megabyte
TotalReservedMemory 273,09 Megabyte
HttpClient with "Accept-Encoding", "gzip":
TotalAllocatedMemory 100,64 Megabyte
TotalReservedMemory 274,09 Megabyte
UnityWebRequest:
TotalAllocatedMemory 116,39 Megabyte
TotalReservedMemory 289,65 Megabyte
UnityWebRequest with "Accept-Encoding", "gzip":
TotalAllocatedMemory 104,44 Megabyte
TotalReservedMemory 278,09 Megabyte
Amazing results, UnityWebRequest even with “Accept-Encoding” and spamming warnings to console/logs it allocates less memory than pure UnityWebRequest due to much smaller response size. Interesting to see how response size doesn’t matter for HttpClient (yes I did test if response size was gzipped, was 800kb down to 200kb).
Gzip tests include deserialization of the content, http client does:
HttpClientHandler handler = new HttpClientHandler()
{
AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate
};
client = new HttpClient( handler );
Uwr what I’ve sent before in this thread.
#Edit
One more test x100 requests:
HttpClient
TotalAllocatedMemory 100,70 Megabyte
TotalReservedMemory 274,09 Megabyte
UnityWebRequest
TotalAllocatedMemory 185,12 Megabyte
TotalReservedMemory 357,80 Megabyte
OK I’m definitely switching to HttpClient.
More in UnityWebRequest allocates way more memory than HttpClient