Skip to content

Commit 52969e4

Browse files
committed
Exposing additional extension points in .NET bindings
For the .NET implementation of HttpCommandExecutor, we now expose a Proxy property for proxying requests between the .NET code and the remote end WebDriver implementation. Note carefully that this is entirely separate from the proxy used by the browser for monitoring communications between the browser and the server hosting the page being automated. Additionally, this change exposes the IsKeepAliveEnabled property to make it easier to set whether or not the "keep alive" header is sent when communicating between the language bindings and the remote end WebDriver implementation. Finally, for local use, the DriverServiceCommandExecutor now exposes a property to allow the user to set tho newly-exposed properties by allowing access to the internal HttpCommandExecutor of the driver service.
1 parent 29e9746 commit 52969e4

2 files changed

Lines changed: 34 additions & 2 deletions

File tree

dotnet/src/webdriver/Remote/DriverServiceCommandExecutor.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace OpenQA.Selenium.Remote
2323
/// <summary>
2424
/// Provides a mechanism to execute commands on the browser
2525
/// </summary>
26-
internal class DriverServiceCommandExecutor : ICommandExecutor
26+
public class DriverServiceCommandExecutor : ICommandExecutor
2727
{
2828
private DriverService service;
2929
private HttpCommandExecutor internalExecutor;
@@ -60,6 +60,15 @@ public CommandInfoRepository CommandInfoRepository
6060
get { return this.internalExecutor.CommandInfoRepository; }
6161
}
6262

63+
/// <summary>
64+
/// Gets the <see cref="HttpCommandExecutor"/> that sends commands to the remote
65+
/// end WebDriver implementation.
66+
/// </summary>
67+
public HttpCommandExecutor HttpExecutor
68+
{
69+
get { return this.internalExecutor; }
70+
}
71+
6372
/// <summary>
6473
/// Executes a command
6574
/// </summary>

dotnet/src/webdriver/Remote/HttpCommandExecutor.cs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public class HttpCommandExecutor : ICommandExecutor
4141
private TimeSpan serverResponseTimeout;
4242
private bool enableKeepAlive;
4343
private bool isDisposed;
44+
private IWebProxy proxy;
4445
private CommandInfoRepository commandInfoRepository = new WebDriverWireProtocolCommandInfoRepository();
4546

4647
/// <summary>
@@ -101,6 +102,28 @@ public CommandInfoRepository CommandInfoRepository
101102
get { return this.commandInfoRepository; }
102103
}
103104

105+
/// <summary>
106+
/// Gets or sets an <see cref="IWebProxy"/> object to be used to proxy requests
107+
/// between this <see cref="HttpCommandExecutor"/> and the remote end WebDriver
108+
/// implementation.
109+
/// </summary>
110+
public IWebProxy Proxy
111+
{
112+
get { return this.proxy; }
113+
set { this.proxy = value; }
114+
}
115+
116+
/// <summary>
117+
/// Gets or sets a value indicating whether keep-alive is enabled for HTTP
118+
/// communication between this <see cref="HttpCommandExecutor"/> and the
119+
/// remote end WebDriver implementation.
120+
/// </summary>
121+
public bool IsKeepAliveEnabled
122+
{
123+
get { return this.enableKeepAlive; }
124+
set { this.enableKeepAlive = value; }
125+
}
126+
104127
/// <summary>
105128
/// Executes a command
106129
/// </summary>
@@ -186,7 +209,7 @@ private HttpResponseInfo MakeHttpRequest(HttpRequestInfo requestInfo)
186209
request.Timeout = (int)this.serverResponseTimeout.TotalMilliseconds;
187210
request.Accept = RequestAcceptHeader;
188211
request.KeepAlive = this.enableKeepAlive;
189-
request.Proxy = null;
212+
request.Proxy = this.proxy;
190213
request.ServicePoint.ConnectionLimit = 2000;
191214
if (request.Method == CommandInfo.GetCommand)
192215
{

0 commit comments

Comments
 (0)