/// <summary> /// Continues request with optional request overrides. To use this, request interception should be enabled with <see cref="Page.SetRequestInterceptionAsync(bool)"/>. Exception is immediately thrown if the request interception is not enabled. /// If the URL is set it won't perform a redirect. The request will be silently forwarded to the new url. For example, the address bar will show the original url. /// </summary> /// <param name="overrides">Optional request overwrites.</param> /// <returns>Task</returns> public async Task ContinueAsync(Payload overrides = null) { // Request interception is not supported for data: urls. if (Url.StartsWith("data:", StringComparison.InvariantCultureIgnoreCase)) { return; } if (!_allowInterception) { throw new PuppeteerException("Request Interception is not enabled!"); } if (_interceptionHandled) { throw new PuppeteerException("Request is already handled!"); } _interceptionHandled = true; try { var requestData = new FetchContinueRequestRequest { RequestId = InterceptionId }; if (overrides?.Url != null) { requestData.Url = overrides.Url; } if (overrides?.Method != null) { requestData.Method = overrides.Method.ToString(); } if (overrides?.PostData != null) { requestData.PostData = Convert.ToBase64String(Encoding.UTF8.GetBytes(overrides?.PostData)); } if (overrides?.Headers?.Count > 0) { requestData.Headers = HeadersArray(overrides.Headers); } await _client.SendAsync("Fetch.continueRequest", requestData).ConfigureAwait(false); } catch (PuppeteerException ex) { // In certain cases, protocol will return error if the request was already canceled // or the page was closed. We should tolerate these errors _logger.LogError(ex.ToString()); } }
/// <summary> /// Continues request with optional request overrides. To use this, request interception should be enabled with <see cref="Page.SetRequestInterceptionAsync(bool)"/>. Exception is immediately thrown if the request interception is not enabled. /// If the URL is set it won't perform a redirect. The request will be silently forwarded to the new url. For example, the address bar will show the original url. /// </summary> /// <param name="overrides">Optional request overwrites.</param> /// <returns>Task</returns> public async Task ContinueAsync(Payload overrides = null) { // Request interception is not supported for data: urls. if (Url.StartsWith("data:", StringComparison.InvariantCultureIgnoreCase)) { return; } if (!_allowInterception) { throw new PuppeteerException("Request Interception is not enabled!"); } if (_interceptionHandled) { throw new PuppeteerException("Request is already handled!"); } _interceptionHandled = true; try { var requestData = new FetchContinueRequestRequest { RequestId = InterceptionId }; if (overrides?.Url != null) { requestData.Url = overrides.Url; } if (overrides?.Method != null) { requestData.Method = overrides.Method.ToString(); } if (overrides?.PostData != null) { requestData.PostData = overrides.PostData; } if (overrides?.Headers?.Count > 0) { requestData.Headers = HeadersArray(overrides.Headers); } await _client.SendAsync("Fetch.continueRequest", requestData).ConfigureAwait(false); } catch (PuppeteerException) { } }