2424using System . Text ;
2525using System . Threading . Tasks ;
2626
27+ #nullable enable
28+
2729namespace OpenQA . Selenium . DevTools . V130
2830{
2931 /// <summary>
@@ -41,8 +43,8 @@ public class V130Network : DevTools.Network
4143 /// <param name="fetch">The adapter for the Fetch domain.</param>
4244 public V130Network ( NetworkAdapter network , FetchAdapter fetch )
4345 {
44- this . network = network ;
45- this . fetch = fetch ;
46+ this . network = network ?? throw new ArgumentNullException ( nameof ( network ) ) ;
47+ this . fetch = fetch ?? throw new ArgumentNullException ( nameof ( fetch ) ) ;
4648 fetch . AuthRequired += OnFetchAuthRequired ;
4749 fetch . RequestPaused += OnFetchRequestPaused ;
4850 }
@@ -101,7 +103,7 @@ await fetch.Enable(new Fetch.EnableCommandSettings()
101103 }
102104
103105 /// <summary>
104- /// Asynchronously diables the fetch domain.
106+ /// Asynchronously disables the fetch domain.
105107 /// </summary>
106108 /// <returns>A task that represents the asynchronous operation.</returns>
107109 public override async Task DisableFetch ( )
@@ -114,8 +116,14 @@ public override async Task DisableFetch()
114116 /// </summary>
115117 /// <param name="userAgent">A <see cref="UserAgent"/> object containing the user agent values to override.</param>
116118 /// <returns>A task that represents the asynchronous operation.</returns>
119+ /// <exception cref="ArgumentNullException">If <paramref name="userAgent"/> is null.</exception>
117120 public override async Task SetUserAgentOverride ( UserAgent userAgent )
118121 {
122+ if ( userAgent is null )
123+ {
124+ throw new ArgumentNullException ( nameof ( userAgent ) ) ;
125+ }
126+
119127 await network . SetUserAgentOverride ( new SetUserAgentOverrideCommandSettings ( )
120128 {
121129 UserAgent = userAgent . UserAgentString ,
@@ -129,8 +137,14 @@ await network.SetUserAgentOverride(new SetUserAgentOverrideCommandSettings()
129137 /// </summary>
130138 /// <param name="requestData">The <see cref="HttpRequestData"/> of the request.</param>
131139 /// <returns>A task that represents the asynchronous operation.</returns>
140+ /// <exception cref="ArgumentNullException">If <paramref name="requestData"/> is <see langword="null"/>.</exception>
132141 public override async Task ContinueRequest ( HttpRequestData requestData )
133142 {
143+ if ( requestData is null )
144+ {
145+ throw new ArgumentNullException ( nameof ( requestData ) ) ;
146+ }
147+
134148 var commandSettings = new ContinueRequestCommandSettings ( )
135149 {
136150 RequestId = requestData . RequestId ,
@@ -163,8 +177,19 @@ public override async Task ContinueRequest(HttpRequestData requestData)
163177 /// <param name="requestData">The <see cref="HttpRequestData"/> of the request.</param>
164178 /// <param name="responseData">The <see cref="HttpResponseData"/> with which to respond to the request</param>
165179 /// <returns>A task that represents the asynchronous operation.</returns>
180+ /// <exception cref="ArgumentNullException">If <paramref name="requestData"/> or <paramref name="responseData"/> are <see langword="null"/>.</exception>
166181 public override async Task ContinueRequestWithResponse ( HttpRequestData requestData , HttpResponseData responseData )
167182 {
183+ if ( requestData is null )
184+ {
185+ throw new ArgumentNullException ( nameof ( requestData ) ) ;
186+ }
187+
188+ if ( responseData is null )
189+ {
190+ throw new ArgumentNullException ( nameof ( responseData ) ) ;
191+ }
192+
168193 var commandSettings = new FulfillRequestCommandSettings ( )
169194 {
170195 RequestId = requestData . RequestId ,
@@ -196,12 +221,18 @@ public override async Task ContinueRequestWithResponse(HttpRequestData requestDa
196221 }
197222
198223 /// <summary>
199- /// Asynchronously contines an intercepted network call without modification.
224+ /// Asynchronously continues an intercepted network call without modification.
200225 /// </summary>
201226 /// <param name="requestData">The <see cref="HttpRequestData"/> of the network call.</param>
202227 /// <returns>A task that represents the asynchronous operation.</returns>
228+ /// <exception cref="ArgumentNullException">If <paramref name="requestData"/> is <see langword="null"/>.</exception>
203229 public override async Task ContinueRequestWithoutModification ( HttpRequestData requestData )
204230 {
231+ if ( requestData is null )
232+ {
233+ throw new ArgumentNullException ( nameof ( requestData ) ) ;
234+ }
235+
205236 await fetch . ContinueRequest ( new ContinueRequestCommandSettings ( ) { RequestId = requestData . RequestId } ) . ConfigureAwait ( false ) ;
206237 }
207238
@@ -212,7 +243,7 @@ public override async Task ContinueRequestWithoutModification(HttpRequestData re
212243 /// <param name="userName">The user name with which to authenticate.</param>
213244 /// <param name="password">The password with which to authenticate.</param>
214245 /// <returns>A task that represents the asynchronous operation.</returns>
215- public override async Task ContinueWithAuth ( string requestId , string userName , string password )
246+ public override async Task ContinueWithAuth ( string requestId , string ? userName , string ? password )
216247 {
217248 await fetch . ContinueWithAuth ( new ContinueWithAuthCommandSettings ( )
218249 {
@@ -248,8 +279,14 @@ await fetch.ContinueWithAuth(new ContinueWithAuthCommandSettings()
248279 /// </summary>
249280 /// <param name="responseData">The <see cref="HttpResponseData"/> object to which to add the response body.</param>
250281 /// <returns>A task that represents the asynchronous operation.</returns>
282+ /// <exception cref="ArgumentNullException">If <paramref name="responseData"/> is <see langword="null"/>.</exception>
251283 public override async Task AddResponseBody ( HttpResponseData responseData )
252284 {
285+ if ( responseData is null )
286+ {
287+ throw new ArgumentNullException ( nameof ( responseData ) ) ;
288+ }
289+
253290 // If the response is a redirect, retrieving the body will throw an error in CDP.
254291 if ( responseData . StatusCode < 300 || responseData . StatusCode > 399 )
255292 {
@@ -273,12 +310,18 @@ public override async Task AddResponseBody(HttpResponseData responseData)
273310 /// </summary>
274311 /// <param name="responseData">The <see cref="HttpResponseData"/> of the network response.</param>
275312 /// <returns>A task that represents the asynchronous operation.</returns>
313+ /// <exception cref="ArgumentNullException">If <paramref name="responseData"/> is <see langword="null"/>.</exception>
276314 public override async Task ContinueResponseWithoutModification ( HttpResponseData responseData )
277315 {
316+ if ( responseData is null )
317+ {
318+ throw new ArgumentNullException ( nameof ( responseData ) ) ;
319+ }
320+
278321 await fetch . ContinueResponse ( new ContinueResponseCommandSettings ( ) { RequestId = responseData . RequestId } ) . ConfigureAwait ( false ) ;
279322 }
280323
281- private void OnFetchAuthRequired ( object sender , Fetch . AuthRequiredEventArgs e )
324+ private void OnFetchAuthRequired ( object ? sender , Fetch . AuthRequiredEventArgs e )
282325 {
283326 AuthRequiredEventArgs wrapped = new AuthRequiredEventArgs
284327 (
@@ -289,7 +332,7 @@ private void OnFetchAuthRequired(object sender, Fetch.AuthRequiredEventArgs e)
289332 this . OnAuthRequired ( wrapped ) ;
290333 }
291334
292- private void OnFetchRequestPaused ( object sender , Fetch . RequestPausedEventArgs e )
335+ private void OnFetchRequestPaused ( object ? sender , Fetch . RequestPausedEventArgs e )
293336 {
294337 if ( e . ResponseErrorReason == null && e . ResponseStatusCode == null )
295338 {
0 commit comments