Skip to content

Commit 26b625a

Browse files
committed
[dotnet] Fix HttpCommandExecutor events
This is mainly for the purpose of fixing the ability to get the information of what HTTP requests are being sent to the remote end of the WebDriver session.
1 parent cfde816 commit 26b625a

File tree

2 files changed

+26
-30
lines changed

2 files changed

+26
-30
lines changed

dotnet/src/webdriver/Remote/HttpCommandExecutor.cs

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ private void CreateHttpClient()
232232
}
233233

234234
httpClientHandler.Proxy = this.Proxy;
235-
// httpClientHandler.MaxConnectionsPerServer = 2000;
236235

237236
this.client = new HttpClient(httpClientHandler);
238237
string userAgentString = string.Format(CultureInfo.InvariantCulture, UserAgentHeaderTemplate, ResourceUtilities.AssemblyVersion, ResourceUtilities.PlatformFamily);
@@ -249,7 +248,7 @@ private void CreateHttpClient()
249248

250249
private async Task<HttpResponseInfo> MakeHttpRequest(HttpRequestInfo requestInfo)
251250
{
252-
SendingRemoteHttpRequestEventArgs eventArgs = new SendingRemoteHttpRequestEventArgs(null, requestInfo.RequestBody);
251+
SendingRemoteHttpRequestEventArgs eventArgs = new SendingRemoteHttpRequestEventArgs(requestInfo.HttpMethod, requestInfo.FullUri.ToString(), requestInfo.RequestBody);
253252
this.OnSendingRemoteHttpRequest(eventArgs);
254253

255254
HttpMethod method = new HttpMethod(requestInfo.HttpMethod);
@@ -301,29 +300,6 @@ private Response CreateResponse(HttpResponseInfo responseInfo)
301300
response.Value = body;
302301
}
303302

304-
//if (this.CommandInfoRepository.SpecificationLevel < 1 && (responseInfo.StatusCode < HttpStatusCode.OK || responseInfo.StatusCode >= HttpStatusCode.BadRequest))
305-
//{
306-
// if (responseInfo.StatusCode >= HttpStatusCode.BadRequest && responseInfo.StatusCode < HttpStatusCode.InternalServerError)
307-
// {
308-
// response.Status = WebDriverResult.UnhandledError;
309-
// }
310-
// else if (responseInfo.StatusCode >= HttpStatusCode.InternalServerError)
311-
// {
312-
// if (responseInfo.StatusCode == HttpStatusCode.NotImplemented)
313-
// {
314-
// response.Status = WebDriverResult.UnknownCommand;
315-
// }
316-
// else if (response.Status == WebDriverResult.Success)
317-
// {
318-
// response.Status = WebDriverResult.UnhandledError;
319-
// }
320-
// }
321-
// else
322-
// {
323-
// response.Status = WebDriverResult.UnhandledError;
324-
// }
325-
//}
326-
327303
if (response.Value is string)
328304
{
329305
response.Value = ((string)response.Value).Replace("\r\n", "\n").Replace("\n", Environment.NewLine);

dotnet/src/webdriver/Remote/SendingRemoteHttpRequestEventArgs.cs

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,46 @@ namespace OpenQA.Selenium.Remote
2626
/// </summary>
2727
public class SendingRemoteHttpRequestEventArgs : EventArgs
2828
{
29-
private HttpWebRequest request;
29+
private string method;
30+
private string fullUrl;
3031
private string requestBody;
3132

3233
/// <summary>
3334
/// Initializes a new instance of the <see cref="SendingRemoteHttpRequestEventArgs"/> class.
3435
/// </summary>
35-
/// <param name="request">The <see cref="HttpWebRequest"/> object being sent.</param>
36+
/// <param name="method">The HTTP method of the request being sent.</param>
37+
/// <param name="fullUrl">The full URL of the request being sent.</param>
3638
/// <param name="requestBody">The body of the request.</param>
37-
public SendingRemoteHttpRequestEventArgs(HttpWebRequest request, string requestBody)
39+
public SendingRemoteHttpRequestEventArgs(string method, string fullUrl, string requestBody)
3840
{
39-
this.request = request;
41+
this.method = method;
42+
this.fullUrl = fullUrl;
4043
this.requestBody = requestBody;
4144
}
4245

4346
/// <summary>
4447
/// Gets the <see cref="HttpWebRequest"/> object representing the HTTP request being sent.
4548
/// </summary>
49+
[Obsolete("Bindings no longer use HttpWebRequest. This property will return null, and will be removed in a future release.")]
4650
public HttpWebRequest Request
4751
{
48-
get { return this.request; }
52+
get { return null; }
53+
}
54+
55+
/// <summary>
56+
/// Gets the HTTP method for the HTTP request.
57+
/// </summary>
58+
public string Method
59+
{
60+
get { return this.method; }
61+
}
62+
63+
/// <summary>
64+
/// Gets the full URL of the HTTP request.
65+
/// </summary>
66+
public string FullUrl
67+
{
68+
get { return this.fullUrl; }
4969
}
5070

5171
/// <summary>

0 commit comments

Comments
 (0)