CssSolution/CSS_Solution/Request/HttpClientPool.cs

26 lines
743 B
C#

using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CSS_Solution.Request
{
public class HttpClientPool
{
HttpClient[] httpClients = new HttpClient[5];
public HttpClientPool()
{
for (int i = 0; i < httpClients.Length; i++)
if(i==(int)Request_Type.to_course)
httpClients[i] = new HttpClient(new HttpClientHandler() { AllowAutoRedirect = false });
else
httpClients[i] = new HttpClient();
}
public HttpClient getHttpClient(Request_Type request_Type) => httpClients[(int)request_Type];
}
}