1818
1919using System ;
2020using System . Collections . Generic ;
21+ using System . Text ;
2122using System . Threading . Tasks ;
2223using OpenQA . Selenium . DevTools . V84 . Fetch ;
2324using OpenQA . Selenium . DevTools . V84 . Network ;
@@ -63,6 +64,16 @@ public override async Task EnableNetworkCaching()
6364 await network . SetCacheDisabled ( new SetCacheDisabledCommandSettings ( ) { CacheDisabled = false } ) ;
6465 }
6566
67+ public override async Task EnableNetwork ( )
68+ {
69+ await network . Enable ( new Network . EnableCommandSettings ( ) ) ;
70+ }
71+
72+ public override async Task DisableNetwork ( )
73+ {
74+ await network . Disable ( ) ;
75+ }
76+
6677 /// <summary>
6778 /// Asynchronously enables the fetch domain for all URL patterns.
6879 /// </summary>
@@ -115,8 +126,7 @@ public override async Task ContinueRequest(HttpRequestData requestData, HttpResp
115126
116127 if ( ! string . IsNullOrEmpty ( responseData . Body ) )
117128 {
118- // TODO: base64 encode?
119- commandSettings . Body = responseData . Body ;
129+ commandSettings . Body = Convert . ToBase64String ( Encoding . UTF8 . GetBytes ( responseData . Body ) ) ;
120130 }
121131
122132 await fetch . FulfillRequest ( commandSettings ) ;
@@ -135,14 +145,15 @@ public override async Task ContinueWithoutModification(HttpRequestData requestDa
135145 /// <summary>
136146 /// Asynchronously continues an intercepted network call using authentication.
137147 /// </summary>
138- /// <param name="requestData ">The <see cref="HttpRequestData"/> of the network request.</param>
148+ /// <param name="requestId ">The ID of the network request for which to continue with authentication .</param>
139149 /// <param name="userName">The user name with which to authenticate.</param>
140150 /// <param name="password">The password with which to authenticate.</param>
141151 /// <returns>A task that represents the asynchronous operation.</returns>
142- public override async Task ContinueWithAuth ( HttpRequestData requestData , string userName , string password )
152+ public override async Task ContinueWithAuth ( string requestId , string userName , string password )
143153 {
144154 await fetch . ContinueWithAuth ( new ContinueWithAuthCommandSettings ( )
145155 {
156+ RequestId = requestId ,
146157 AuthChallengeResponse = new OpenQA . Selenium . DevTools . V84 . Fetch . AuthChallengeResponse ( )
147158 {
148159 Response = OpenQA . Selenium . DevTools . V84 . Fetch . AuthChallengeResponseResponseValues . ProvideCredentials ,
@@ -155,12 +166,13 @@ await fetch.ContinueWithAuth(new ContinueWithAuthCommandSettings()
155166 /// <summary>
156167 /// Asynchronously cancels authorization of an intercepted network request.
157168 /// </summary>
158- /// <param name="requestData ">The <see cref="HttpRequestData"/> of the network request.</param>
169+ /// <param name="requestId ">The ID of the network request for which to cancel authentication .</param>
159170 /// <returns>A task that represents the asynchronous operation.</returns>
160- public override async Task CancelAuth ( HttpRequestData requestData )
171+ public override async Task CancelAuth ( string requestId )
161172 {
162173 await fetch . ContinueWithAuth ( new ContinueWithAuthCommandSettings ( )
163174 {
175+ RequestId = requestId ,
164176 AuthChallengeResponse = new OpenQA . Selenium . DevTools . V84 . Fetch . AuthChallengeResponse ( )
165177 {
166178 Response = OpenQA . Selenium . DevTools . V84 . Fetch . AuthChallengeResponseResponseValues . CancelAuth
@@ -173,7 +185,7 @@ private void OnFetchAuthRequired(object sender, Fetch.AuthRequiredEventArgs e)
173185 AuthRequiredEventArgs wrapped = new AuthRequiredEventArgs ( )
174186 {
175187 RequestId = e . RequestId ,
176- Uri = e . AuthChallenge . Origin
188+ Uri = e . Request . Url
177189 } ;
178190
179191 this . OnAuthRequired ( wrapped ) ;
0 commit comments