Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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/Remote/HttpCommandExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ private async Task<HttpResponseInfo> MakeHttpRequest(HttpRequestInfo requestInfo
acceptHeader.CharSet = Utf8CharsetType;
requestMessage.Headers.Accept.Add(acceptHeader);

byte[] bytes = Encoding.UTF8.GetBytes(eventArgs.RequestBody);
byte[] bytes = Encoding.UTF8.GetBytes(requestInfo.RequestBody);
requestMessage.Content = new ByteArrayContent(bytes, 0, bytes.Length);

MediaTypeHeaderValue contentTypeHeader = new MediaTypeHeaderValue(JsonMimeType);
Expand Down
38 changes: 14 additions & 24 deletions dotnet/src/webdriver/Remote/SendingRemoteHttpRequestEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,63 +20,51 @@
using System;
using System.Collections.Generic;

#nullable enable

namespace OpenQA.Selenium.Remote
{
/// <summary>
/// Provides data for the SendingRemoteHttpRequest event of a <see cref="HttpCommandExecutor"/> object.
/// </summary>
public class SendingRemoteHttpRequestEventArgs : EventArgs
{
private string method;
private string fullUrl;
private string requestBody;
private Dictionary<string, string> headers = new Dictionary<string, string>();
private readonly Dictionary<string, string> headers = new Dictionary<string, string>();

/// <summary>
/// Initializes a new instance of the <see cref="SendingRemoteHttpRequestEventArgs"/> class.
/// </summary>
/// <param name="method">The HTTP method of the request being sent.</param>
/// <param name="fullUrl">The full URL of the request being sent.</param>
/// <param name="requestBody">The body of the request.</param>
public SendingRemoteHttpRequestEventArgs(string method, string fullUrl, string requestBody)
/// <exception cref="ArgumentNullException">If <paramref name="method"/>, <paramref name="fullUrl"/> are null.</exception>
public SendingRemoteHttpRequestEventArgs(string method, string fullUrl, string? requestBody)
{
this.method = method;
this.fullUrl = fullUrl;
this.requestBody = requestBody;
this.Method = method ?? throw new ArgumentNullException(nameof(method));
this.FullUrl = fullUrl ?? throw new ArgumentNullException(nameof(fullUrl));
this.RequestBody = requestBody;
}

/// <summary>
/// Gets the HTTP method for the HTTP request.
/// </summary>
public string Method
{
get { return this.method; }
}
public string Method { get; }

/// <summary>
/// Gets the full URL of the HTTP request.
/// </summary>
public string FullUrl
{
get { return this.fullUrl; }
}
public string FullUrl { get; }

/// <summary>
/// Gets the body of the HTTP request as a string.
/// </summary>
public string RequestBody
{
get { return this.requestBody; }
}
public string? RequestBody { get; }

/// <summary>
/// Gets a read-only dictionary of the headers of the HTTP request.
/// Does not include default headers of the web client making the request.
/// </summary>
public IReadOnlyDictionary<string, string> Headers
{
get { return this.headers; }
}
public IReadOnlyDictionary<string, string> Headers => this.headers;

/// <summary>
/// Adds a header to the HTTP request.
Expand All @@ -88,6 +76,8 @@ public IReadOnlyDictionary<string, string> Headers
/// HTTP request being sent; however, be aware they may be overwritten by
/// the client raising the event.
/// </remarks>
/// <exception cref="ArgumentException">If <paramref name="headerName"/> is <see langword="null"/> or <see cref="string.Empty"/>.</exception>
/// <exception cref="ArgumentNullException">If <paramref name="headerValue"/> is <see langword="null"/>.</exception>
public void AddHeader(string headerName, string headerValue)
{
if (string.IsNullOrEmpty(headerName))
Expand Down
Loading