File tree Expand file tree Collapse file tree 2 files changed +30
-17
lines changed Expand file tree Collapse file tree 2 files changed +30
-17
lines changed Original file line number Diff line number Diff line change 1- /*
1+ /*
22MIT LICENSE
33
44Copyright 2017 Digital Ruby, LLC - http://www.digitalruby.com
@@ -26,22 +26,32 @@ public sealed class APIRequestMaker : IAPIRequestMaker
2626 {
2727 private readonly IAPIRequestHandler api ;
2828
29- internal class InternalHttpWebRequest : IHttpWebRequest
29+ /// <summary>
30+ /// Proxy for http requests, reads from HTTP_PROXY environment var by default
31+ /// You can also set via code if you like
32+ /// </summary>
33+ public static WebProxy ? Proxy { get ; set ; }
34+
35+ /// <summary>
36+ /// Static constructor
37+ /// </summary>
38+ static APIRequestMaker ( )
39+ {
40+ var httpProxy = Environment . GetEnvironmentVariable ( "http_proxy" ) ;
41+ httpProxy ??= Environment . GetEnvironmentVariable ( "HTTP_PROXY" ) ;
42+
43+ if ( string . IsNullOrWhiteSpace ( httpProxy ) )
44+ {
45+ return ;
46+ }
47+
48+ var uri = new Uri ( httpProxy ) ;
49+ Proxy = new WebProxy ( uri ) ;
50+
51+ }
52+ internal class InternalHttpWebRequest : IHttpWebRequest
3053 {
3154 internal readonly HttpWebRequest Request ;
32- internal static WebProxy Proxy ;
33-
34- static InternalHttpWebRequest ( )
35- {
36- var httpProxy = Environment . GetEnvironmentVariable ( "http_proxy" ) ;
37- httpProxy ??= Environment . GetEnvironmentVariable ( "HTTP_PROXY" ) ;
38-
39- if ( string . IsNullOrEmpty ( httpProxy ) )
40- return ;
41-
42- var uri = new Uri ( httpProxy ) ;
43- Proxy = new WebProxy ( uri ) ;
44- }
4555
4656 public InternalHttpWebRequest ( Uri fullUri )
4757 {
Original file line number Diff line number Diff line change 1- /*
1+ /*
22MIT LICENSE
33
44Copyright 2017 Digital Ruby, LLC - http://www.digitalruby.com
@@ -91,7 +91,10 @@ private class ClientWebSocketImplementation : IClientWebSocketImplementation
9191 {
9292 private readonly System . Net . WebSockets . ClientWebSocket webSocket = new System . Net . WebSockets . ClientWebSocket ( )
9393 {
94- Options = { Proxy = APIRequestMaker . InternalHttpWebRequest . Proxy }
94+ Options =
95+ {
96+ Proxy = APIRequestMaker . Proxy
97+ }
9598 } ;
9699
97100 public WebSocketState State
You can’t perform that action at this time.
0 commit comments