Skip to content

Commit 710304c

Browse files
RenderMichaelnvborisenko
authored andcommitted
[dotnet] Add back in a public parameterless constructor to HttpRequestData (SeleniumHQ#15258)
* [dotnet] Add back in a public parameterless constructor to `HttpRequestData` * Improve nullability * Make RequestId only settable internally * Revert "Make RequestId only settable internally" This reverts commit d0afea9. * Handle nullability, make new constructor internal * Apply suggestions from code review Simplify null check Co-authored-by: Nikolay Borisenko <[email protected]> * Update dotnet/src/webdriver/HttpRequestData.cs --------- Co-authored-by: Nikolay Borisenko <[email protected]>
1 parent 40db886 commit 710304c

File tree

6 files changed

+22
-20
lines changed

6 files changed

+22
-20
lines changed

dotnet/src/webdriver/DevTools/v130/V130Network.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public override async Task ContinueRequest(HttpRequestData requestData)
153153
Url = requestData.Url,
154154
};
155155

156-
if (requestData.Headers.Count > 0)
156+
if (requestData.Headers?.Count > 0)
157157
{
158158
List<HeaderEntry> headers = new List<HeaderEntry>();
159159
foreach (KeyValuePair<string, string> headerPair in requestData.Headers)

dotnet/src/webdriver/DevTools/v131/V131Network.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public override async Task ContinueRequest(HttpRequestData requestData)
153153
Url = requestData.Url,
154154
};
155155

156-
if (requestData.Headers.Count > 0)
156+
if (requestData.Headers?.Count > 0)
157157
{
158158
List<HeaderEntry> headers = new List<HeaderEntry>();
159159
foreach (KeyValuePair<string, string> headerPair in requestData.Headers)

dotnet/src/webdriver/DevTools/v132/V132Network.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public override async Task ContinueRequest(HttpRequestData requestData)
153153
Url = requestData.Url,
154154
};
155155

156-
if (requestData.Headers.Count > 0)
156+
if (requestData.Headers?.Count > 0)
157157
{
158158
List<HeaderEntry> headers = new List<HeaderEntry>();
159159
foreach (KeyValuePair<string, string> headerPair in requestData.Headers)

dotnet/src/webdriver/DevTools/v85/V85Network.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public override async Task ContinueRequest(HttpRequestData requestData)
153153
Url = requestData.Url,
154154
};
155155

156-
if (requestData.Headers.Count > 0)
156+
if (requestData.Headers?.Count > 0)
157157
{
158158
List<HeaderEntry> headers = new List<HeaderEntry>();
159159
foreach (KeyValuePair<string, string> headerPair in requestData.Headers)
@@ -304,7 +304,7 @@ public override async Task AddResponseBody(HttpResponseData responseData)
304304
}
305305

306306
/// <summary>
307-
/// Asynchronously contines an intercepted network response without modification.
307+
/// Asynchronously contiunes an intercepted network response without modification.
308308
/// </summary>
309309
/// <param name="responseData">The <see cref="HttpResponseData"/> of the network response.</param>
310310
/// <returns>A task that represents the asynchronous operation.</returns>

dotnet/src/webdriver/HttpRequestData.cs

+9-10
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,11 @@ public class HttpRequestData
3131
/// <summary>
3232
/// Initializes a new instance of the <see cref="HttpRequestData"/> type.
3333
/// </summary>
34-
/// <param name="method">The method of the HTTP request.</param>
35-
/// <param name="url">The URL of the HTTP request.</param>
36-
/// <param name="postData">The POST data of the HTTP request.</param>
37-
/// <param name="headers">The headers of the HTTP request.</param>
38-
/// <param name="requestId">The ID of the HTTP request.</param>
39-
public HttpRequestData(string method, string url, string? postData, Dictionary<string, string> headers, string requestId)
34+
public HttpRequestData()
35+
{
36+
}
37+
38+
internal HttpRequestData(string? method, string? url, string? postData, Dictionary<string, string>? headers, string? requestId)
4039
{
4140
this.Method = method;
4241
this.Url = url;
@@ -48,12 +47,12 @@ public HttpRequestData(string method, string url, string? postData, Dictionary<s
4847
/// <summary>
4948
/// Gets the method of the HTTP request.
5049
/// </summary>
51-
public string Method { get; set; }
50+
public string? Method { get; set; }
5251

5352
/// <summary>
5453
/// Gets the URL of the HTTP request.
5554
/// </summary>
56-
public string Url { get; set; }
55+
public string? Url { get; set; }
5756

5857
/// <summary>
5958
/// Gets the POST data of the HTTP request, if any.
@@ -63,11 +62,11 @@ public HttpRequestData(string method, string url, string? postData, Dictionary<s
6362
/// <summary>
6463
/// Gets the headers of the HTTP request.
6564
/// </summary>
66-
public Dictionary<string, string> Headers { get; set; }
65+
public Dictionary<string, string>? Headers { get; set; }
6766

6867
/// <summary>
6968
/// Gets the ID of the HTTP request.
7069
/// </summary>
71-
public string RequestId { get; }
70+
public string? RequestId { get; }
7271
}
7372
}

dotnet/src/webdriver/NetworkRequestSentEventArgs.cs

+8-5
Original file line numberDiff line numberDiff line change
@@ -41,26 +41,29 @@ public NetworkRequestSentEventArgs(HttpRequestData requestData)
4141
this.RequestUrl = requestData.Url;
4242
this.RequestMethod = requestData.Method;
4343
this.RequestPostData = requestData.PostData;
44-
foreach (KeyValuePair<string, string> header in requestData.Headers)
44+
if (requestData.Headers != null)
4545
{
46-
this.requestHeaders[header.Key] = header.Value;
46+
foreach (KeyValuePair<string, string> header in requestData.Headers)
47+
{
48+
this.requestHeaders[header.Key] = header.Value;
49+
}
4750
}
4851
}
4952

5053
/// <summary>
5154
/// Gets the internal request ID of the network request.
5255
/// </summary>
53-
public string RequestId { get; }
56+
public string? RequestId { get; }
5457

5558
/// <summary>
5659
/// Gets the URL of the network request.
5760
/// </summary>
58-
public string RequestUrl { get; }
61+
public string? RequestUrl { get; }
5962

6063
/// <summary>
6164
/// Gets the HTTP method of the network request.
6265
/// </summary>
63-
public string RequestMethod { get; }
66+
public string? RequestMethod { get; }
6467

6568
/// <summary>
6669
/// Gets the post data of the network request, if any.

0 commit comments

Comments
 (0)