Skip to content
This repository has been archived by the owner on Jan 16, 2023. It is now read-only.

Commit

Permalink
gzip + connection limit are back
Browse files Browse the repository at this point in the history
  • Loading branch information
kasthack committed Dec 2, 2014
1 parent 8aedeb3 commit 2b29556
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Sources/VKSharp/Data/Executors/JsonExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Reflection;
using System.Threading.Tasks;
Expand All @@ -15,7 +16,7 @@ namespace VKSharp.Data.Executors {
public class JsonExecutor : IExecutor {
#region IO
private const string ReqExt = "json";
private static readonly HttpClient Client = new HttpClient();
private static readonly HttpClient Client;
private static async Task<string> ExecRawAsync<T>( VKRequest<T> request, string format ) {
var ps = request.Parameters.ToList();
ps.Add( new KeyValuePair<string, string>( "v", "5.21" ) );
Expand All @@ -35,6 +36,11 @@ private static async Task<string> ExecRawAsync<T>( VKRequest<T> request, string
private static readonly JsonSerializer Jsonser;

static JsonExecutor() {
ServicePointManager.DefaultConnectionLimit = Math.Max(25, ServicePointManager.DefaultConnectionLimit);
var httpClientHandler = new HttpClientHandler();
if (httpClientHandler.SupportsAutomaticDecompression)
httpClientHandler.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;
Client = new HttpClient( httpClientHandler );
var snakeCaseContractResolver = new SnakeCaseContractResolver();
snakeCaseContractResolver.DefaultMembersSearchFlags |= BindingFlags.NonPublic;
Jsonser = new JsonSerializer { ContractResolver = snakeCaseContractResolver };
Expand Down

0 comments on commit 2b29556

Please sign in to comment.