|
18 | 18 | using Aliyun.OTS.Handler; |
19 | 19 | using Aliyun.OTS.DataModel.ConditionalUpdate; |
20 | 20 | using System; |
| 21 | +using System.Net; |
| 22 | +using System.Net.Http; |
21 | 23 |
|
22 | 24 | namespace Aliyun.OTS |
23 | 25 | { |
@@ -47,7 +49,8 @@ public class OTSClient |
47 | 49 | { |
48 | 50 | #region Fields & Properties |
49 | 51 |
|
50 | | - private OTSConnectionPool ConnectionPool; |
| 52 | + private HttpClient client; |
| 53 | + |
51 | 54 | private OTSHandler OTSHandler; |
52 | 55 | private OTSClientConfig ClientConfig; |
53 | 56 |
|
@@ -78,11 +81,9 @@ public OTSClient(OTSClientConfig config) |
78 | 81 | ClientConfig = config; |
79 | 82 | OTSHandler = new OTSHandler(); |
80 | 83 |
|
81 | | - ConnectionPool = new OTSConnectionPool( |
82 | | - ClientConfig.EndPoint, |
83 | | - ClientConfig.ConnectionLimit |
84 | | - ); |
85 | | - |
| 84 | + client = new HttpClient(); |
| 85 | + client.BaseAddress = new Uri(ClientConfig.EndPoint); |
| 86 | + ServicePointManager.DefaultConnectionLimit = config.ConnectionLimit; |
86 | 87 | OTSClientTestHelper.Reset(); |
87 | 88 | } |
88 | 89 |
|
@@ -674,13 +675,13 @@ private Task<TResponse> CallAsync<TRequest, TResponse>(string apiName, TRequest |
674 | 675 | otsContext.APIName = apiName; |
675 | 676 | otsContext.OTSRequest = request; |
676 | 677 | otsContext.OTSReponse = new TResponse(); |
677 | | - otsContext.HttpClient = ConnectionPool.TakeHttpClient(); |
| 678 | + otsContext.HttpClient = client; |
678 | 679 |
|
679 | 680 | OTSHandler.HandleBefore(otsContext); |
680 | 681 |
|
681 | 682 | return otsContext.HttpTask.ContinueWith((t) => |
682 | 683 | { |
683 | | - ConnectionPool.ReturnHttpClient(otsContext.HttpClient); |
| 684 | + // ConnectionPool.ReturnHttpClient(otsContext.HttpClient); |
684 | 685 | OTSHandler.HandleAfter(otsContext); |
685 | 686 | return (TResponse)otsContext.OTSReponse; |
686 | 687 | }); |
|
0 commit comments