24
24
using System . Text ;
25
25
using System . Threading . Tasks ;
26
26
27
+ #nullable enable
28
+
27
29
namespace OpenQA . Selenium . DevTools . V130
28
30
{
29
31
/// <summary>
@@ -39,10 +41,11 @@ public class V130Network : DevTools.Network
39
41
/// </summary>
40
42
/// <param name="network">The adapter for the Network domain.</param>
41
43
/// <param name="fetch">The adapter for the Fetch domain.</param>
44
+ /// <exception cref="ArgumentNullException">If <paramref name="network"/> or <paramref name="fetch"/> are <see langword="null"/>.</exception>
42
45
public V130Network ( NetworkAdapter network , FetchAdapter fetch )
43
46
{
44
- this . network = network ;
45
- this . fetch = fetch ;
47
+ this . network = network ?? throw new ArgumentNullException ( nameof ( network ) ) ;
48
+ this . fetch = fetch ?? throw new ArgumentNullException ( nameof ( fetch ) ) ;
46
49
fetch . AuthRequired += OnFetchAuthRequired ;
47
50
fetch . RequestPaused += OnFetchRequestPaused ;
48
51
}
@@ -101,7 +104,7 @@ await fetch.Enable(new Fetch.EnableCommandSettings()
101
104
}
102
105
103
106
/// <summary>
104
- /// Asynchronously diables the fetch domain.
107
+ /// Asynchronously disables the fetch domain.
105
108
/// </summary>
106
109
/// <returns>A task that represents the asynchronous operation.</returns>
107
110
public override async Task DisableFetch ( )
@@ -114,8 +117,14 @@ public override async Task DisableFetch()
114
117
/// </summary>
115
118
/// <param name="userAgent">A <see cref="UserAgent"/> object containing the user agent values to override.</param>
116
119
/// <returns>A task that represents the asynchronous operation.</returns>
120
+ /// <exception cref="ArgumentNullException">If <paramref name="userAgent"/> is null.</exception>
117
121
public override async Task SetUserAgentOverride ( UserAgent userAgent )
118
122
{
123
+ if ( userAgent is null )
124
+ {
125
+ throw new ArgumentNullException ( nameof ( userAgent ) ) ;
126
+ }
127
+
119
128
await network . SetUserAgentOverride ( new SetUserAgentOverrideCommandSettings ( )
120
129
{
121
130
UserAgent = userAgent . UserAgentString ,
@@ -129,8 +138,14 @@ await network.SetUserAgentOverride(new SetUserAgentOverrideCommandSettings()
129
138
/// </summary>
130
139
/// <param name="requestData">The <see cref="HttpRequestData"/> of the request.</param>
131
140
/// <returns>A task that represents the asynchronous operation.</returns>
141
+ /// <exception cref="ArgumentNullException">If <paramref name="requestData"/> is <see langword="null"/>.</exception>
132
142
public override async Task ContinueRequest ( HttpRequestData requestData )
133
143
{
144
+ if ( requestData is null )
145
+ {
146
+ throw new ArgumentNullException ( nameof ( requestData ) ) ;
147
+ }
148
+
134
149
var commandSettings = new ContinueRequestCommandSettings ( )
135
150
{
136
151
RequestId = requestData . RequestId ,
@@ -163,8 +178,19 @@ public override async Task ContinueRequest(HttpRequestData requestData)
163
178
/// <param name="requestData">The <see cref="HttpRequestData"/> of the request.</param>
164
179
/// <param name="responseData">The <see cref="HttpResponseData"/> with which to respond to the request</param>
165
180
/// <returns>A task that represents the asynchronous operation.</returns>
181
+ /// <exception cref="ArgumentNullException">If <paramref name="requestData"/> or <paramref name="responseData"/> are <see langword="null"/>.</exception>
166
182
public override async Task ContinueRequestWithResponse ( HttpRequestData requestData , HttpResponseData responseData )
167
183
{
184
+ if ( requestData is null )
185
+ {
186
+ throw new ArgumentNullException ( nameof ( requestData ) ) ;
187
+ }
188
+
189
+ if ( responseData is null )
190
+ {
191
+ throw new ArgumentNullException ( nameof ( responseData ) ) ;
192
+ }
193
+
168
194
var commandSettings = new FulfillRequestCommandSettings ( )
169
195
{
170
196
RequestId = requestData . RequestId ,
@@ -196,12 +222,18 @@ public override async Task ContinueRequestWithResponse(HttpRequestData requestDa
196
222
}
197
223
198
224
/// <summary>
199
- /// Asynchronously contines an intercepted network call without modification.
225
+ /// Asynchronously continues an intercepted network call without modification.
200
226
/// </summary>
201
227
/// <param name="requestData">The <see cref="HttpRequestData"/> of the network call.</param>
202
228
/// <returns>A task that represents the asynchronous operation.</returns>
229
+ /// <exception cref="ArgumentNullException">If <paramref name="requestData"/> is <see langword="null"/>.</exception>
203
230
public override async Task ContinueRequestWithoutModification ( HttpRequestData requestData )
204
231
{
232
+ if ( requestData is null )
233
+ {
234
+ throw new ArgumentNullException ( nameof ( requestData ) ) ;
235
+ }
236
+
205
237
await fetch . ContinueRequest ( new ContinueRequestCommandSettings ( ) { RequestId = requestData . RequestId } ) . ConfigureAwait ( false ) ;
206
238
}
207
239
@@ -212,7 +244,7 @@ public override async Task ContinueRequestWithoutModification(HttpRequestData re
212
244
/// <param name="userName">The user name with which to authenticate.</param>
213
245
/// <param name="password">The password with which to authenticate.</param>
214
246
/// <returns>A task that represents the asynchronous operation.</returns>
215
- public override async Task ContinueWithAuth ( string requestId , string userName , string password )
247
+ public override async Task ContinueWithAuth ( string requestId , string ? userName , string ? password )
216
248
{
217
249
await fetch . ContinueWithAuth ( new ContinueWithAuthCommandSettings ( )
218
250
{
@@ -248,8 +280,14 @@ await fetch.ContinueWithAuth(new ContinueWithAuthCommandSettings()
248
280
/// </summary>
249
281
/// <param name="responseData">The <see cref="HttpResponseData"/> object to which to add the response body.</param>
250
282
/// <returns>A task that represents the asynchronous operation.</returns>
283
+ /// <exception cref="ArgumentNullException">If <paramref name="responseData"/> is <see langword="null"/>.</exception>
251
284
public override async Task AddResponseBody ( HttpResponseData responseData )
252
285
{
286
+ if ( responseData is null )
287
+ {
288
+ throw new ArgumentNullException ( nameof ( responseData ) ) ;
289
+ }
290
+
253
291
// If the response is a redirect, retrieving the body will throw an error in CDP.
254
292
if ( responseData . StatusCode < 300 || responseData . StatusCode > 399 )
255
293
{
@@ -273,12 +311,18 @@ public override async Task AddResponseBody(HttpResponseData responseData)
273
311
/// </summary>
274
312
/// <param name="responseData">The <see cref="HttpResponseData"/> of the network response.</param>
275
313
/// <returns>A task that represents the asynchronous operation.</returns>
314
+ /// <exception cref="ArgumentNullException">If <paramref name="responseData"/> is <see langword="null"/>.</exception>
276
315
public override async Task ContinueResponseWithoutModification ( HttpResponseData responseData )
277
316
{
317
+ if ( responseData is null )
318
+ {
319
+ throw new ArgumentNullException ( nameof ( responseData ) ) ;
320
+ }
321
+
278
322
await fetch . ContinueResponse ( new ContinueResponseCommandSettings ( ) { RequestId = responseData . RequestId } ) . ConfigureAwait ( false ) ;
279
323
}
280
324
281
- private void OnFetchAuthRequired ( object sender , Fetch . AuthRequiredEventArgs e )
325
+ private void OnFetchAuthRequired ( object ? sender , Fetch . AuthRequiredEventArgs e )
282
326
{
283
327
AuthRequiredEventArgs wrapped = new AuthRequiredEventArgs
284
328
(
@@ -289,7 +333,7 @@ private void OnFetchAuthRequired(object sender, Fetch.AuthRequiredEventArgs e)
289
333
this . OnAuthRequired ( wrapped ) ;
290
334
}
291
335
292
- private void OnFetchRequestPaused ( object sender , Fetch . RequestPausedEventArgs e )
336
+ private void OnFetchRequestPaused ( object ? sender , Fetch . RequestPausedEventArgs e )
293
337
{
294
338
if ( e . ResponseErrorReason == null && e . ResponseStatusCode == null )
295
339
{
0 commit comments