Skip to content

Commit 5d3c959

Browse files
committed
SetExtraHeaders
1 parent 2a8261d commit 5d3c959

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ namespace OpenQA.Selenium.BiDi.Communication.Json;
131131
[JsonSerializable(typeof(Network.RemoveDataCollectorCommand))]
132132
[JsonSerializable(typeof(Network.RemoveInterceptCommand))]
133133
[JsonSerializable(typeof(Network.SetCacheBehaviorCommand))]
134+
[JsonSerializable(typeof(Network.SetExtraHeadersCommand))]
134135

135136
[JsonSerializable(typeof(Network.BeforeRequestSentEventArgs))]
136137
[JsonSerializable(typeof(Network.ResponseStartedEventArgs))]

dotnet/src/webdriver/BiDi/Network/NetworkModule.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ public async Task<EmptyResult> SetCacheBehaviorAsync(CacheBehavior behavior, Set
6565
return await Broker.ExecuteCommandAsync<SetCacheBehaviorCommand, EmptyResult>(new SetCacheBehaviorCommand(@params), options).ConfigureAwait(false);
6666
}
6767

68+
public async Task<EmptyResult> SetExtraHeadersAsync(IEnumerable<Header> headers, SetExtraHeadersOptions? options = null)
69+
{
70+
var @params = new SetExtraHeadersParameters(headers, options?.Contexts, options?.UserContexts);
71+
72+
return await Broker.ExecuteCommandAsync<SetExtraHeadersCommand, EmptyResult>(new SetExtraHeadersCommand(@params), options).ConfigureAwait(false);
73+
}
74+
6875
public async Task<EmptyResult> ContinueRequestAsync(Request request, ContinueRequestOptions? options = null)
6976
{
7077
var @params = new ContinueRequestParameters(request, options?.Body, options?.Cookies, options?.Headers, options?.Method, options?.Url);
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// <copyright file="SetExtraHeadersCommand.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.Collections.Generic;
21+
using OpenQA.Selenium.BiDi.Communication;
22+
23+
namespace OpenQA.Selenium.BiDi.Network;
24+
25+
internal sealed class SetExtraHeadersCommand(SetExtraHeadersParameters @params)
26+
: Command<SetExtraHeadersParameters, EmptyResult>(@params, "network.setExtraHeaders");
27+
28+
internal sealed record SetExtraHeadersParameters(IEnumerable<Header> Headers, IEnumerable<BrowsingContext.BrowsingContext>? Contexts, IEnumerable<Browser.UserContext>? UserContexts) : Parameters;
29+
30+
public sealed class SetExtraHeadersOptions : CommandOptions
31+
{
32+
public IEnumerable<BrowsingContext.BrowsingContext>? Contexts { get; set; }
33+
34+
public IEnumerable<Browser.UserContext>? UserContexts { get; set; }
35+
}

0 commit comments

Comments
 (0)