Skip to content

Commit e4f1bd2

Browse files
Meir017kblok
authored andcommitted
Filter out "intervention" header (#908)
1 parent c76e244 commit e4f1bd2

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

lib/PuppeteerSharp.Tests/PageTests/SetRequestInterceptionTests.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,35 @@ public async Task ShouldIntercept()
3838
};
3939
var response = await Page.GoToAsync(TestConstants.EmptyPage);
4040
Assert.True(response.Ok);
41+
4142
Assert.Equal(TestConstants.Port, response.RemoteAddress.Port);
4243
}
4344

45+
[Fact]
46+
public async Task ShouldWorkWithInterventionHeaders()
47+
{
48+
Server.SetRoute("/intervention", context => context.Response.WriteAsync($@"
49+
<script>
50+
document.write('<script src=""{TestConstants.CrossProcessHttpPrefix}/intervention.js"">' + '</scr' + 'ipt>');
51+
</script>
52+
"));
53+
Server.SetRedirect("/intervention.js", "/redirect.js");
54+
55+
string interventionHeader = null;
56+
Server.SetRoute("/redirect.js", context =>
57+
{
58+
interventionHeader = context.Request.Headers["intervention"];
59+
return context.Response.WriteAsync("console.log(1);");
60+
});
61+
62+
await Page.SetRequestInterceptionAsync(true);
63+
Page.Request += async (sender, e) => await e.Request.ContinueAsync();
64+
65+
await Page.GoToAsync(TestConstants.ServerUrl + "/intervention");
66+
67+
Assert.Contains("www.chromestatus.com", interventionHeader);
68+
}
69+
4470
[Fact]
4571
public async Task ShouldWorkWhenPostIsEedirectedWith302()
4672
{

lib/PuppeteerSharp/Payload.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ public class Payload
2121
"x-devtools-emulate-network-conditions-client-id",
2222
"cookie",
2323
"origin",
24-
"content-type"
24+
"content-type",
25+
"intervention"
2526
};
2627

2728
/// <summary>

0 commit comments

Comments
 (0)