Skip to content

[dotnet] Add back in a public parameterless constructor to HttpRequestData #15258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Feb 9, 2025
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dotnet/src/webdriver/DevTools/v130/V130Network.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public override async Task ContinueRequest(HttpRequestData requestData)
Url = requestData.Url,
};

if (requestData.Headers.Count > 0)
if (requestData.Headers != null && requestData.Headers.Count > 0)
{
List<HeaderEntry> headers = new List<HeaderEntry>();
foreach (KeyValuePair<string, string> headerPair in requestData.Headers)
Expand Down
2 changes: 1 addition & 1 deletion dotnet/src/webdriver/DevTools/v131/V131Network.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public override async Task ContinueRequest(HttpRequestData requestData)
Url = requestData.Url,
};

if (requestData.Headers.Count > 0)
if (requestData.Headers != null && requestData.Headers.Count > 0)
{
List<HeaderEntry> headers = new List<HeaderEntry>();
foreach (KeyValuePair<string, string> headerPair in requestData.Headers)
Expand Down
2 changes: 1 addition & 1 deletion dotnet/src/webdriver/DevTools/v132/V132Network.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public override async Task ContinueRequest(HttpRequestData requestData)
Url = requestData.Url,
};

if (requestData.Headers.Count > 0)
if (requestData.Headers != null && requestData.Headers.Count > 0)
{
List<HeaderEntry> headers = new List<HeaderEntry>();
foreach (KeyValuePair<string, string> headerPair in requestData.Headers)
Expand Down
4 changes: 2 additions & 2 deletions dotnet/src/webdriver/DevTools/v85/V85Network.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public override async Task ContinueRequest(HttpRequestData requestData)
Url = requestData.Url,
};

if (requestData.Headers.Count > 0)
if (requestData.Headers != null && requestData.Headers.Count > 0)
{
List<HeaderEntry> headers = new List<HeaderEntry>();
foreach (KeyValuePair<string, string> headerPair in requestData.Headers)
Expand Down Expand Up @@ -304,7 +304,7 @@ public override async Task AddResponseBody(HttpResponseData responseData)
}

/// <summary>
/// Asynchronously contines an intercepted network response without modification.
/// Asynchronously contiunes an intercepted network response without modification.
/// </summary>
/// <param name="responseData">The <see cref="HttpResponseData"/> of the network response.</param>
/// <returns>A task that represents the asynchronous operation.</returns>
Expand Down
19 changes: 9 additions & 10 deletions dotnet/src/webdriver/HttpRequestData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ public class HttpRequestData
/// <summary>
/// Initializes a new instance of the <see cref="HttpRequestData"/> type.
/// </summary>
/// <param name="method">The method of the HTTP request.</param>
/// <param name="url">The URL of the HTTP request.</param>
/// <param name="postData">The POST data of the HTTP request.</param>
/// <param name="headers">The headers of the HTTP request.</param>
/// <param name="requestId">The ID of the HTTP request.</param>
public HttpRequestData(string method, string url, string? postData, Dictionary<string, string> headers, string requestId)
public HttpRequestData()
{
}

internal HttpRequestData(string method, string url, string? postData, Dictionary<string, string> headers, string requestId)
{
this.Method = method;
this.Url = url;
Expand All @@ -48,12 +47,12 @@ public HttpRequestData(string method, string url, string? postData, Dictionary<s
/// <summary>
/// Gets the method of the HTTP request.
/// </summary>
public string Method { get; set; }
public string? Method { get; set; }

/// <summary>
/// Gets the URL of the HTTP request.
/// </summary>
public string Url { get; set; }
public string? Url { get; set; }

/// <summary>
/// Gets the POST data of the HTTP request, if any.
Expand All @@ -63,11 +62,11 @@ public HttpRequestData(string method, string url, string? postData, Dictionary<s
/// <summary>
/// Gets the headers of the HTTP request.
/// </summary>
public Dictionary<string, string> Headers { get; set; }
public Dictionary<string, string>? Headers { get; set; }

/// <summary>
/// Gets the ID of the HTTP request.
/// </summary>
public string RequestId { get; }
public string? RequestId { get; }
}
}
13 changes: 8 additions & 5 deletions dotnet/src/webdriver/NetworkRequestSentEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,29 @@ public NetworkRequestSentEventArgs(HttpRequestData requestData)
this.RequestUrl = requestData.Url;
this.RequestMethod = requestData.Method;
this.RequestPostData = requestData.PostData;
foreach (KeyValuePair<string, string> header in requestData.Headers)
if (requestData.Headers != null)
{
this.requestHeaders[header.Key] = header.Value;
foreach (KeyValuePair<string, string> header in requestData.Headers)
{
this.requestHeaders[header.Key] = header.Value;
}
}
}

/// <summary>
/// Gets the internal request ID of the network request.
/// </summary>
public string RequestId { get; }
public string? RequestId { get; }

/// <summary>
/// Gets the URL of the network request.
/// </summary>
public string RequestUrl { get; }
public string? RequestUrl { get; }

/// <summary>
/// Gets the HTTP method of the network request.
/// </summary>
public string RequestMethod { get; }
public string? RequestMethod { get; }

/// <summary>
/// Gets the post data of the network request, if any.
Expand Down
Loading