@@ -25,52 +25,58 @@ namespace OpenQA.Selenium.BiDi.BrowsingContext;
2525
2626public sealed class BrowsingContextNetworkModule ( BrowsingContext context , NetworkModule networkModule )
2727{
28- public async Task < Intercept > InterceptRequestAsync ( Func < InterceptedRequest , Task > handler , InterceptRequestOptions ? options = null )
28+ public async Task < Interception > InterceptRequestAsync ( Func < InterceptedRequest , Task > handler , InterceptRequestOptions ? options = null )
2929 {
3030 AddInterceptOptions addInterceptOptions = new ( options )
3131 {
3232 Contexts = [ context ]
3333 } ;
3434
35- var intercept = await networkModule . AddInterceptAsync ( [ InterceptPhase . BeforeRequestSent ] , addInterceptOptions ) . ConfigureAwait ( false ) ;
35+ var interceptResult = await networkModule . AddInterceptAsync ( [ InterceptPhase . BeforeRequestSent ] , addInterceptOptions ) . ConfigureAwait ( false ) ;
3636
37- await intercept . OnBeforeRequestSentAsync (
37+ Interception interception = new ( context . BiDi , interceptResult . Intercept ) ;
38+
39+ await interception . OnBeforeRequestSentAsync (
3840 async req => await handler ( new ( req . BiDi , req . Context , req . IsBlocked , req . Navigation , req . RedirectCount , req . Request , req . Timestamp , req . Initiator , req . Intercepts ) ) ,
3941 new ( ) { Contexts = [ context ] } ) . ConfigureAwait ( false ) ;
4042
41- return intercept ;
43+ return interception ;
4244 }
4345
44- public async Task < Intercept > InterceptResponseAsync ( Func < InterceptedResponse , Task > handler , InterceptResponseOptions ? options = null )
46+ public async Task < Interception > InterceptResponseAsync ( Func < InterceptedResponse , Task > handler , InterceptResponseOptions ? options = null )
4547 {
4648 AddInterceptOptions addInterceptOptions = new ( options )
4749 {
4850 Contexts = [ context ]
4951 } ;
5052
51- var intercept = await networkModule . AddInterceptAsync ( [ InterceptPhase . ResponseStarted ] , addInterceptOptions ) . ConfigureAwait ( false ) ;
53+ var interceptResult = await networkModule . AddInterceptAsync ( [ InterceptPhase . ResponseStarted ] , addInterceptOptions ) . ConfigureAwait ( false ) ;
54+
55+ Interception interception = new ( context . BiDi , interceptResult . Intercept ) ;
5256
53- await intercept . OnResponseStartedAsync (
57+ await interception . OnResponseStartedAsync (
5458 async res => await handler ( new ( res . BiDi , res . Context , res . IsBlocked , res . Navigation , res . RedirectCount , res . Request , res . Timestamp , res . Response , res . Intercepts ) ) ,
5559 new ( ) { Contexts = [ context ] } ) . ConfigureAwait ( false ) ;
5660
57- return intercept ;
61+ return interception ;
5862 }
5963
60- public async Task < Intercept > InterceptAuthAsync ( Func < InterceptedAuth , Task > handler , InterceptAuthOptions ? options = null )
64+ public async Task < Interception > InterceptAuthAsync ( Func < InterceptedAuth , Task > handler , InterceptAuthOptions ? options = null )
6165 {
6266 AddInterceptOptions addInterceptOptions = new ( options )
6367 {
6468 Contexts = [ context ]
6569 } ;
6670
67- var intercept = await networkModule . AddInterceptAsync ( [ InterceptPhase . AuthRequired ] , addInterceptOptions ) . ConfigureAwait ( false ) ;
71+ var interceptResult = await networkModule . AddInterceptAsync ( [ InterceptPhase . AuthRequired ] , addInterceptOptions ) . ConfigureAwait ( false ) ;
72+
73+ Interception interception = new ( context . BiDi , interceptResult . Intercept ) ;
6874
69- await intercept . OnAuthRequiredAsync (
75+ await interception . OnAuthRequiredAsync (
7076 async auth => await handler ( new ( auth . BiDi , auth . Context , auth . IsBlocked , auth . Navigation , auth . RedirectCount , auth . Request , auth . Timestamp , auth . Response , auth . Intercepts ) ) ,
7177 new ( ) { Contexts = [ context ] } ) . ConfigureAwait ( false ) ;
7278
73- return intercept ;
79+ return interception ;
7480 }
7581
7682 public Task < SetCacheBehaviorResult > SetCacheBehaviorAsync ( CacheBehavior behavior , BrowsingContextSetCacheBehaviorOptions ? options = null )
0 commit comments