| 
 | 1 | +// <copyright file="NetworkModule.HighLevel.cs" company="Selenium Committers">  | 
 | 2 | +// Licensed to the Software Freedom Conservancy (SFC) under one  | 
 | 3 | +// or more contributor license agreements.  See the NOTICE file  | 
 | 4 | +// distributed with this work for additional information  | 
 | 5 | +// regarding copyright ownership.  The SFC licenses this file  | 
 | 6 | +// to you under the Apache License, Version 2.0 (the  | 
 | 7 | +// "License"); you may not use this file except in compliance  | 
 | 8 | +// with the License.  You may obtain a copy of the License at  | 
 | 9 | +//  | 
 | 10 | +//   http://www.apache.org/licenses/LICENSE-2.0  | 
 | 11 | +//  | 
 | 12 | +// Unless required by applicable law or agreed to in writing,  | 
 | 13 | +// software distributed under the License is distributed on an  | 
 | 14 | +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY  | 
 | 15 | +// KIND, either express or implied.  See the License for the  | 
 | 16 | +// specific language governing permissions and limitations  | 
 | 17 | +// under the License.  | 
 | 18 | +// </copyright>  | 
 | 19 | + | 
 | 20 | +using System;  | 
 | 21 | +using System.Threading.Tasks;  | 
 | 22 | + | 
 | 23 | +namespace OpenQA.Selenium.BiDi.Modules.Network;  | 
 | 24 | + | 
 | 25 | +public partial class NetworkModule  | 
 | 26 | +{  | 
 | 27 | +    public async Task<Intercept> InterceptRequestAsync(Func<BeforeRequestSentEventArgs, Task> handler, InterceptRequestOptions? options = null)  | 
 | 28 | +    {  | 
 | 29 | +        var intercept = await AddInterceptAsync([InterceptPhase.BeforeRequestSent], options).ConfigureAwait(false);  | 
 | 30 | + | 
 | 31 | +        await intercept.OnBeforeRequestSentAsync(handler).ConfigureAwait(false);  | 
 | 32 | + | 
 | 33 | +        return intercept;  | 
 | 34 | +    }  | 
 | 35 | + | 
 | 36 | +    public async Task<Intercept> InterceptResponseAsync(Func<ResponseStartedEventArgs, Task> handler, InterceptResponseOptions? options = null)  | 
 | 37 | +    {  | 
 | 38 | +        var intercept = await AddInterceptAsync([InterceptPhase.ResponseStarted], options).ConfigureAwait(false);  | 
 | 39 | + | 
 | 40 | +        await intercept.OnResponseStartedAsync(handler).ConfigureAwait(false);  | 
 | 41 | + | 
 | 42 | +        return intercept;  | 
 | 43 | +    }  | 
 | 44 | + | 
 | 45 | +    public async Task<Intercept> InterceptAuthAsync(Func<AuthRequiredEventArgs, Task> handler, InterceptAuthOptions? options = null)  | 
 | 46 | +    {  | 
 | 47 | +        var intercept = await AddInterceptAsync([InterceptPhase.AuthRequired], options).ConfigureAwait(false);  | 
 | 48 | + | 
 | 49 | +        await intercept.OnAuthRequiredAsync(handler).ConfigureAwait(false);  | 
 | 50 | + | 
 | 51 | +        return intercept;  | 
 | 52 | +    }  | 
 | 53 | +}  | 
 | 54 | + | 
 | 55 | +public record InterceptRequestOptions : AddInterceptOptions;  | 
 | 56 | + | 
 | 57 | +public record InterceptResponseOptions : AddInterceptOptions;  | 
 | 58 | + | 
 | 59 | +public record InterceptAuthOptions : AddInterceptOptions;  | 
0 commit comments