This commit is contained in:
@@ -23,7 +23,8 @@ namespace AyaNova.PlugIn.V8
|
||||
public const string API_BASE_ROUTE = "api/v8/";
|
||||
private const int MAX_TRIES = 3;//max times to retry an api call before giving up
|
||||
private const int API_RETRY_DELAY = 3000;//pause in ms before retrying api call
|
||||
public static HttpClient client = new HttpClient();
|
||||
private const int HTTPCLIENT_TIMEOUT_SECONDS = 300;//default for all ops, normally 100seconds but would kill large file uploads
|
||||
public static HttpClient client = null;
|
||||
//url once known to be good
|
||||
internal static string ApiBaseUrl { get; set; }
|
||||
internal static string JWT { get; set; }
|
||||
@@ -41,6 +42,13 @@ namespace AyaNova.PlugIn.V8
|
||||
#region INIT / AUTH
|
||||
private static void InitClient()
|
||||
{
|
||||
if (client != null)
|
||||
{
|
||||
client.Dispose();
|
||||
client = null;
|
||||
}
|
||||
client = new HttpClient();
|
||||
client.Timeout = TimeSpan.FromSeconds(HTTPCLIENT_TIMEOUT_SECONDS);
|
||||
|
||||
//client.Timeout = new TimeSpan(0, 0, 45);
|
||||
//client.BaseAddress = new Uri(ApiBaseUrl);
|
||||
@@ -384,6 +392,7 @@ namespace AyaNova.PlugIn.V8
|
||||
requestMessage.Content = formContent;
|
||||
|
||||
|
||||
|
||||
HttpResponseMessage response = null;
|
||||
try
|
||||
{
|
||||
@@ -402,7 +411,7 @@ namespace AyaNova.PlugIn.V8
|
||||
var responseAsString = await response.Content.ReadAsStringAsync();
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
throw new Exception("POST FORMDATA error, code: "+ (int)response.StatusCode + ", route: " + route + "\r\n" + responseAsString + "\r\n" + response.ReasonPhrase);
|
||||
throw new Exception("POST FORMDATA error, code: " + (int)response.StatusCode + ", route: " + route + "\r\n" + responseAsString + "\r\n" + response.ReasonPhrase);
|
||||
}
|
||||
else
|
||||
return new ApiResponse() { HttpResponse = response, ObjectResponse = Parse(responseAsString) };
|
||||
|
||||
Reference in New Issue
Block a user