forked from bsmg/ModAssistant
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHttp.cs
More file actions
40 lines (33 loc) · 1.05 KB
/
Copy pathHttp.cs
File metadata and controls
40 lines (33 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using System.Net;
using System.Net.Http;
using System.Web.Script.Serialization;
namespace ModAssistant
{
static class Http
{
private static HttpClient _client = null;
public static HttpClient HttpClient
{
get
{
if (_client != null) return _client;
var handler = new HttpClientHandler()
{
AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate,
};
_client = new HttpClient(handler)
{
Timeout = TimeSpan.FromSeconds(240),
};
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
_client.DefaultRequestHeaders.Add("User-Agent", "ModAssistant/" + App.Version);
return _client;
}
}
public static JavaScriptSerializer JsonSerializer = new JavaScriptSerializer()
{
MaxJsonLength = int.MaxValue,
};
}
}