private async Task OnRequestPausedAsync(FetchRequestPausedResponse e) { if (!_userRequestInterceptionEnabled && _protocolRequestInterceptionEnabled) { try { await _client.SendAsync("Fetch.continueRequest", new FetchContinueRequestRequest { RequestId = e.RequestId }).ConfigureAwait(false); } catch (PuppeteerException ex) { _logger.LogError(ex.ToString()); } } var requestId = e.NetworkId; var interceptionId = e.RequestId; if (!string.IsNullOrEmpty(requestId)) { if (_requestIdToRequestWillBeSentEvent.TryRemove(requestId, out var requestWillBeSentEvent)) { await OnRequestAsync(requestWillBeSentEvent, interceptionId).ConfigureAwait(false); } else { _requestIdToInterceptionId[requestId] = interceptionId; } } }
private async Task OnRequestPausedAsync(FetchRequestPausedResponse e) { if (!_userRequestInterceptionEnabled && _protocolRequestInterceptionEnabled) { try { await _client.SendAsync("Fetch.continueRequest", new FetchContinueRequestRequest { RequestId = e.RequestId }).ConfigureAwait(false); } catch (PuppeteerException ex) { _logger.LogError(ex.ToString()); } } var requestId = e.NetworkId; var interceptionId = e.RequestId; if (string.IsNullOrEmpty(requestId)) { return; } var hasRequestWillBeSentEvent = _requestIdToRequestWillBeSentEvent.TryGetValue(requestId, out var requestWillBeSentEvent); // redirect requests have the same `requestId` if (hasRequestWillBeSentEvent && (requestWillBeSentEvent.Request.Url != e.Request.Url || requestWillBeSentEvent.Request.Method != e.Request.Method)) { _requestIdToRequestWillBeSentEvent.TryRemove(requestId, out _); hasRequestWillBeSentEvent = false; } if (hasRequestWillBeSentEvent) { await OnRequestAsync(requestWillBeSentEvent, interceptionId).ConfigureAwait(false); _requestIdToRequestWillBeSentEvent.TryRemove(requestId, out _); } else { _requestIdToRequestPausedEvent[requestId] = e; } }