2020using System ;
2121using System . Collections . Generic ;
2222
23+ #nullable enable
24+
2325namespace OpenQA . Selenium . Remote
2426{
2527 /// <summary>
2628 /// Provides data for the SendingRemoteHttpRequest event of a <see cref="HttpCommandExecutor"/> object.
2729 /// </summary>
2830 public class SendingRemoteHttpRequestEventArgs : EventArgs
2931 {
30- private string method ;
31- private string fullUrl ;
32- private string requestBody ;
33- private Dictionary < string , string > headers = new Dictionary < string , string > ( ) ;
32+ private readonly Dictionary < string , string > headers = new Dictionary < string , string > ( ) ;
3433
3534 /// <summary>
3635 /// Initializes a new instance of the <see cref="SendingRemoteHttpRequestEventArgs"/> class.
3736 /// </summary>
3837 /// <param name="method">The HTTP method of the request being sent.</param>
3938 /// <param name="fullUrl">The full URL of the request being sent.</param>
4039 /// <param name="requestBody">The body of the request.</param>
41- public SendingRemoteHttpRequestEventArgs ( string method , string fullUrl , string requestBody )
40+ /// <exception cref="ArgumentNullException">If <paramref name="method"/>, <paramref name="fullUrl"/> are null.</exception>
41+ public SendingRemoteHttpRequestEventArgs ( string method , string fullUrl , string ? requestBody )
4242 {
43- this . method = method ;
44- this . fullUrl = fullUrl ;
45- this . requestBody = requestBody ;
43+ this . Method = method ?? throw new ArgumentNullException ( nameof ( method ) ) ;
44+ this . FullUrl = fullUrl ?? throw new ArgumentNullException ( nameof ( fullUrl ) ) ;
45+ this . RequestBody = requestBody ;
4646 }
4747
4848 /// <summary>
4949 /// Gets the HTTP method for the HTTP request.
5050 /// </summary>
51- public string Method
52- {
53- get { return this . method ; }
54- }
51+ public string Method { get ; }
5552
5653 /// <summary>
5754 /// Gets the full URL of the HTTP request.
5855 /// </summary>
59- public string FullUrl
60- {
61- get { return this . fullUrl ; }
62- }
56+ public string FullUrl { get ; }
6357
6458 /// <summary>
6559 /// Gets the body of the HTTP request as a string.
6660 /// </summary>
67- public string RequestBody
68- {
69- get { return this . requestBody ; }
70- }
61+ public string ? RequestBody { get ; }
7162
7263 /// <summary>
7364 /// Gets a read-only dictionary of the headers of the HTTP request.
7465 /// Does not include default headers of the web client making the request.
7566 /// </summary>
76- public IReadOnlyDictionary < string , string > Headers
77- {
78- get { return this . headers ; }
79- }
67+ public IReadOnlyDictionary < string , string > Headers => this . headers ;
8068
8169 /// <summary>
8270 /// Adds a header to the HTTP request.
@@ -88,6 +76,8 @@ public IReadOnlyDictionary<string, string> Headers
8876 /// HTTP request being sent; however, be aware they may be overwritten by
8977 /// the client raising the event.
9078 /// </remarks>
79+ /// <exception cref="ArgumentException">If <paramref name="headerName"/> is <see langword="null"/> or <see cref="string.Empty"/>.</exception>
80+ /// <exception cref="ArgumentNullException">If <paramref name="headerValue"/> is <see langword="null"/>.</exception>
9181 public void AddHeader ( string headerName , string headerValue )
9282 {
9383 if ( string . IsNullOrEmpty ( headerName ) )
0 commit comments