Skip to content

Commit b950261

Browse files
committed
Fixes REST Client
1 parent 1b6d5a9 commit b950261

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

LanPartyTool/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
2121

22-
[assembly: AssemblyVersion("0.9.10.27")]
23-
[assembly: AssemblyFileVersion("0.9.10.27")]
22+
[assembly: AssemblyVersion("0.9.11.28")]
23+
[assembly: AssemblyFileVersion("0.9.11.28")]
2424

2525
[assembly: XmlConfigurator(ConfigFile = "log4net.config")]
2626
[assembly: Guid("94403695-D3D3-4A0C-A7A8-A8B9FAAF5E9B")]

LanPartyTool/utility/HttpUtility.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using System;
2+
using System.Net;
23
using System.Net.Http;
4+
using System.Windows;
35
using LanPartyTool.agent;
46
using log4net;
57
using Newtonsoft.Json;
@@ -30,17 +32,20 @@ public static dynamic DoPost(string url, dynamic requestBody = null)
3032
request.AddHeader("content-type", "application/json");
3133
request.AddHeader("accept", "application/json");
3234

33-
var client = new RestClient(url) {Timeout = HTTP_CLIENT_TIMEOUT};
35+
var client = new RestClient(url)
36+
{
37+
Timeout = HTTP_CLIENT_TIMEOUT,
38+
UserAgent = Application.ResourceAssembly.FullName
39+
};
40+
3441
var response = client.Execute(request);
35-
if (!response.IsSuccessful)
42+
if (response.StatusCode != HttpStatusCode.OK)
3643
{
3744
Logger.Debug("Unable to complete HTTP request");
3845
return null;
3946
}
4047

41-
var responseString = response.Content;
42-
43-
var responseJson = JsonConvert.DeserializeObject(responseString);
48+
var responseJson = JsonConvert.DeserializeObject(response.Content);
4449
return responseJson;
4550
}
4651
}

0 commit comments

Comments
 (0)