[성현모] VPKI 페이징, csv 다운로드 수정
This commit is contained in:
@ -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()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user