Skip to content

Commit 749b9a9

Browse files
authored
Enable Network Service by default (#912)
1 parent 2e687fc commit 749b9a9

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-14
lines changed

lib/PuppeteerSharp.Tests/PageTests/SetRequestInterceptionTests.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -438,19 +438,6 @@ public async Task ShouldNavigateToDataURLAndFireDataURLRequests()
438438
Assert.Equal(dataURL, requests[0].Url);
439439
}
440440

441-
[Fact]
442-
public async Task ShouldAbortDataServer()
443-
{
444-
await Page.SetRequestInterceptionAsync(true);
445-
Page.Request += async (sender, e) =>
446-
{
447-
await e.Request.AbortAsync();
448-
};
449-
var exception = await Assert.ThrowsAsync<NavigationException>(
450-
() => Page.GoToAsync("data:text/html,No way!"));
451-
Assert.Contains("net::ERR_FAILED", exception.Message);
452-
}
453-
454441
[Fact]
455442
public async Task ShouldNavigateToURLWithHashAndAndFireRequestsWithoutHash()
456443
{

lib/PuppeteerSharp/ChromiumProcess.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public class ChromiumProcess : IDisposable
2222

2323
internal static readonly string[] DefaultArgs = {
2424
"--disable-background-networking",
25+
"--enable-features=NetworkService,NetworkServiceInProcess",
2526
"--disable-background-timer-throttling",
2627
"--disable-backgrounding-occluded-windows",
2728
"--disable-breakpad",

lib/PuppeteerSharp/NetworkManager.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,8 @@ private void HandleRequestRedirect(Request request, ResponsePayload responseMess
342342

343343
private async Task OnRequestWillBeSentAsync(RequestWillBeSentPayload e)
344344
{
345-
if (_protocolRequestInterceptionEnabled)
345+
// Request interception doesn't happen for data URLs with Network Service.
346+
if (_protocolRequestInterceptionEnabled && !e.Request.Url.StartsWith("data:", StringComparison.InvariantCultureIgnoreCase))
346347
{
347348
var requestHash = e.Request.Hash;
348349
var interceptionId = _requestHashToInterceptionIds.FirstValue(requestHash);

lib/PuppeteerSharp/Request.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,11 @@ internal Request(
153153
/// <returns>Task</returns>
154154
public async Task ContinueAsync(Payload overrides = null)
155155
{
156+
// Request interception is not supported for data: urls.
157+
if (Url.StartsWith("data:", StringComparison.InvariantCultureIgnoreCase))
158+
{
159+
return;
160+
}
156161
if (!_allowInterception)
157162
{
158163
throw new PuppeteerException("Request Interception is not enabled!");
@@ -288,6 +293,11 @@ public async Task RespondAsync(ResponseData response)
288293
/// <returns>Task</returns>
289294
public async Task AbortAsync(RequestAbortErrorCode errorCode = RequestAbortErrorCode.Failed)
290295
{
296+
// Request interception is not supported for data: urls.
297+
if (Url.StartsWith("data:", StringComparison.InvariantCultureIgnoreCase))
298+
{
299+
return;
300+
}
291301
if (!_allowInterception)
292302
{
293303
throw new PuppeteerException("Request Interception is not enabled!");

0 commit comments

Comments
 (0)