20
20
using System ;
21
21
using System . Collections . Generic ;
22
22
23
+ #nullable enable
24
+
23
25
namespace OpenQA . Selenium . Remote
24
26
{
25
27
/// <summary>
26
28
/// Provides data for the SendingRemoteHttpRequest event of a <see cref="HttpCommandExecutor"/> object.
27
29
/// </summary>
28
30
public class SendingRemoteHttpRequestEventArgs : EventArgs
29
31
{
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 > ( ) ;
34
33
35
34
/// <summary>
36
35
/// Initializes a new instance of the <see cref="SendingRemoteHttpRequestEventArgs"/> class.
37
36
/// </summary>
38
37
/// <param name="method">The HTTP method of the request being sent.</param>
39
38
/// <param name="fullUrl">The full URL of the request being sent.</param>
40
39
/// <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 )
42
42
{
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 ;
46
46
}
47
47
48
48
/// <summary>
49
49
/// Gets the HTTP method for the HTTP request.
50
50
/// </summary>
51
- public string Method
52
- {
53
- get { return this . method ; }
54
- }
51
+ public string Method { get ; }
55
52
56
53
/// <summary>
57
54
/// Gets the full URL of the HTTP request.
58
55
/// </summary>
59
- public string FullUrl
60
- {
61
- get { return this . fullUrl ; }
62
- }
56
+ public string FullUrl { get ; }
63
57
64
58
/// <summary>
65
59
/// Gets the body of the HTTP request as a string.
66
60
/// </summary>
67
- public string RequestBody
68
- {
69
- get { return this . requestBody ; }
70
- }
61
+ public string ? RequestBody { get ; }
71
62
72
63
/// <summary>
73
64
/// Gets a read-only dictionary of the headers of the HTTP request.
74
65
/// Does not include default headers of the web client making the request.
75
66
/// </summary>
76
- public IReadOnlyDictionary < string , string > Headers
77
- {
78
- get { return this . headers ; }
79
- }
67
+ public IReadOnlyDictionary < string , string > Headers => this . headers ;
80
68
81
69
/// <summary>
82
70
/// Adds a header to the HTTP request.
@@ -88,6 +76,8 @@ public IReadOnlyDictionary<string, string> Headers
88
76
/// HTTP request being sent; however, be aware they may be overwritten by
89
77
/// the client raising the event.
90
78
/// </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>
91
81
public void AddHeader ( string headerName , string headerValue )
92
82
{
93
83
if ( string . IsNullOrEmpty ( headerName ) )
0 commit comments