@@ -114,10 +114,9 @@ public async Task Nested_Proxy_Farm_Without_Connection_Cache_Should_Not_Hang()
114
114
proxy1 . EnableConnectionPool = false ;
115
115
var proxy2 = proxies2 [ rnd . Next ( ) % proxies2 . Count ] ;
116
116
117
- var explicitEndpoint = proxy1 . ProxyEndPoints . OfType < ExplicitProxyEndPoint > ( ) . First ( ) ;
118
- explicitEndpoint . BeforeTunnelConnectRequest += ( _ , e ) =>
117
+ proxy1 . GetCustomUpStreamProxyFunc += async ( _ ) =>
119
118
{
120
- e . CustomUpStreamProxy = new ExternalProxy ( )
119
+ var proxy = new ExternalProxy ( )
121
120
{
122
121
HostName = "localhost" ,
123
122
Port = proxy2 . ProxyEndPoints [ 0 ] . Port ,
@@ -126,21 +125,7 @@ public async Task Nested_Proxy_Farm_Without_Connection_Cache_Should_Not_Hang()
126
125
Password = "test_password"
127
126
} ;
128
127
129
- return Task . CompletedTask ;
130
- } ;
131
-
132
- proxy1 . BeforeRequest += ( _ , e ) =>
133
- {
134
- e . CustomUpStreamProxy = new ExternalProxy ( )
135
- {
136
- HostName = "localhost" ,
137
- Port = proxy2 . ProxyEndPoints [ 0 ] . Port ,
138
- ProxyType = ExternalProxyType . Http ,
139
- UserName = "test_user" ,
140
- Password = "test_password"
141
- } ;
142
-
143
- return Task . CompletedTask ;
128
+ return await Task . FromResult ( proxy ) ;
144
129
} ;
145
130
146
131
proxies1 . Add ( proxy1 ) ;
@@ -164,7 +149,7 @@ await client.PostAsync(new Uri(server.ListeningHttpsUrl),
164
149
new StringContent ( "hello server. I am a client." ) ) ;
165
150
166
151
}
167
- //if error is thrown because of server overloading its okay.
152
+ //if error is thrown because of server getting overloaded its okay.
168
153
//But client.PostAsync should'nt hang in all cases.
169
154
catch { }
170
155
} ) ;
@@ -212,24 +197,10 @@ public async Task Nested_Proxy_Farm_With_Connection_Cache_Should_Not_Hang()
212
197
{
213
198
var proxy1 = testSuite . GetProxy ( ) ;
214
199
var proxy2 = proxies2 [ rnd . Next ( ) % proxies2 . Count ] ;
215
- var explicitEndpoint = proxy1 . ProxyEndPoints . OfType < ExplicitProxyEndPoint > ( ) . First ( ) ;
216
- explicitEndpoint . BeforeTunnelConnectRequest += ( _ , e ) =>
217
- {
218
- e . CustomUpStreamProxy = new ExternalProxy ( )
219
- {
220
- HostName = "localhost" ,
221
- Port = proxy2 . ProxyEndPoints [ 0 ] . Port ,
222
- ProxyType = ExternalProxyType . Http ,
223
- UserName = "test_user" ,
224
- Password = "test_password"
225
- } ;
226
-
227
- return Task . CompletedTask ;
228
- } ;
229
200
230
- proxy1 . BeforeRequest += ( _ , e ) =>
201
+ proxy1 . GetCustomUpStreamProxyFunc += async ( _ ) =>
231
202
{
232
- e . CustomUpStreamProxy = new ExternalProxy ( )
203
+ var proxy = new ExternalProxy ( )
233
204
{
234
205
HostName = "localhost" ,
235
206
Port = proxy2 . ProxyEndPoints [ 0 ] . Port ,
@@ -238,7 +209,7 @@ public async Task Nested_Proxy_Farm_With_Connection_Cache_Should_Not_Hang()
238
209
Password = "test_password"
239
210
} ;
240
211
241
- return Task . CompletedTask ;
212
+ return await Task . FromResult ( proxy ) ;
242
213
} ;
243
214
244
215
proxies1 . Add ( proxy1 ) ;
@@ -261,7 +232,7 @@ public async Task Nested_Proxy_Farm_With_Connection_Cache_Should_Not_Hang()
261
232
await client . PostAsync ( new Uri ( server . ListeningHttpsUrl ) ,
262
233
new StringContent ( "hello server. I am a client." ) ) ;
263
234
}
264
- //if error is thrown because of server overloading its okay.
235
+ //if error is thrown because of server getting overloaded its okay.
265
236
//But client.PostAsync should'nt hang in all cases.
266
237
catch { }
267
238
} ) ;
0 commit comments