[성현모] VPKI 페이징, csv 다운로드 수정

This commit is contained in:
SHM
2025-05-14 09:17:06 +09:00
parent a1553d88bb
commit 3dd406260f
11 changed files with 213 additions and 121 deletions

View File

@ -95,6 +95,40 @@ namespace SystemX.Core.Communication
return response;
}
public virtual async Task<Stream?> GetStreamAsync(string url, string bearerToken = "", short timeOutSeconds = 10)
{
Guid guid = Guid.NewGuid();
Stream stream = null;
using (HttpClient httpClient = new HttpClient(GetClientHandler()))
{
try
{
var timeOutSec = SetTimeout(timeOutSeconds);
httpClient.Timeout = new TimeSpan(0, 0, timeOutSec);
httpClient.BaseAddress = new Uri($"{url}");
if (string.IsNullOrEmpty(bearerToken) == false)
httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", $"{bearerToken}");
Log4net.WriteLine($"[GET] Request({guid})::{url}", LogType.HTTP);
DateTime requestTime = DateTime.Now;
var response = await httpClient.GetAsync(url);
stream = await response.Content.ReadAsStreamAsync();
Log4net.WriteLine($"[GET] Rseponse({guid}) ({(DateTime.Now - requestTime).TotalSeconds} sec)::{url}", LogType.HTTP);
}
catch (Exception e)
{
Log4net.WriteLine(e);
}
}
return stream;
}
protected HttpClientHandler GetClientHandler()
{