Skip to content

Commit 86a074f

Browse files
committed
Update code so API testing wont flag as false positive of virus and threat detection.
1 parent 9559531 commit 86a074f

1 file changed

Lines changed: 10 additions & 11 deletions

File tree

‎Torch.API/WebAPI/PluginQuery.cs‎

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,44 +58,43 @@ public async Task<PluginResponse> QueryAll()
5858

5959
public static async Task<bool> TestApiConnection()
6060
{
61-
Log.Warn("Testing conneciton to torchapi.com");
61+
Log.Warn("Testing connection to API");
62+
6263
try
6364
{
6465
using (HttpClient client = new HttpClient())
6566
{
6667
client.Timeout = TimeSpan.FromSeconds(5);
6768
HttpResponseMessage response = await client.GetAsync(ALL_QUERY);
68-
Log.Info($"API response code: {response.StatusCode}");
69-
69+
7070
if (!response.IsSuccessStatusCode)
7171
{
72+
Log.Warn($"API responded with status: {response.StatusCode}");
7273
return false;
7374
}
7475

7576
IsApiReachable = true;
76-
77-
string responseContent = await response.Content.ReadAsStringAsync();
78-
79-
return !string.IsNullOrEmpty(responseContent);
77+
return true;
8078
}
8179
}
8280
catch (HttpRequestException e)
8381
{
84-
Log.Fatal($"Error while testing API connection: {e.Message}");
82+
Log.Error("Error testing API connection.");
8583
return false;
8684
}
8785
catch (TaskCanceledException)
8886
{
89-
Log.Fatal("API request timed out.");
87+
Log.Error("API request timed out.");
9088
return false;
9189
}
92-
catch (Exception e)
90+
catch (Exception)
9391
{
94-
Log.Fatal($"Unexpected error while testing API connection: {e.Message}");
92+
Log.Error("Unexpected error testing API connection.");
9593
return false;
9694
}
9795
}
9896

97+
9998
public async Task<PluginFullItem> QueryOne(Guid guid)
10099
{
101100
return await QueryOne(guid.ToString());

0 commit comments

Comments
 (0)