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
+ /*
2
2
MIT LICENSE
3
3
4
4
Copyright 2017 Digital Ruby, LLC - http://www.digitalruby.com
@@ -26,22 +26,32 @@ public sealed class APIRequestMaker : IAPIRequestMaker
26
26
{
27
27
private readonly IAPIRequestHandler api ;
28
28
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
30
53
{
31
54
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
- }
45
55
46
56
public InternalHttpWebRequest ( Uri fullUri )
47
57
{
Original file line number Diff line number Diff line change 1
- /*
1
+ /*
2
2
MIT LICENSE
3
3
4
4
Copyright 2017 Digital Ruby, LLC - http://www.digitalruby.com
@@ -91,7 +91,10 @@ private class ClientWebSocketImplementation : IClientWebSocketImplementation
91
91
{
92
92
private readonly System . Net . WebSockets . ClientWebSocket webSocket = new System . Net . WebSockets . ClientWebSocket ( )
93
93
{
94
- Options = { Proxy = APIRequestMaker . InternalHttpWebRequest . Proxy }
94
+ Options =
95
+ {
96
+ Proxy = APIRequestMaker . Proxy
97
+ }
95
98
} ;
96
99
97
100
public WebSocketState State
You can’t perform that action at this time.
0 commit comments