/// <summary> /// Asynchronously adds the response body to the provided <see cref="HttpResponseData"/> object. /// </summary> /// <param name="responseData">The <see cref="HttpResponseData"/> object to which to add the response body.</param> /// <returns>A task that represents the asynchronous operation.</returns> public override async Task AddResponseBody(HttpResponseData responseData) { var bodyResponse = await fetch.GetResponseBody(new Fetch.GetResponseBodyCommandSettings() { RequestId = responseData.RequestId }); if (bodyResponse.Base64Encoded) { responseData.Body = Encoding.UTF8.GetString(Convert.FromBase64String(bodyResponse.Body)); } else { responseData.Body = bodyResponse.Body; } }
/// <summary> /// Asynchronously adds the response body to the provided <see cref="HttpResponseData"/> object. /// </summary> /// <param name="responseData">The <see cref="HttpResponseData"/> object to which to add the response body.</param> /// <returns>A task that represents the asynchronous operation.</returns> public override async Task AddResponseBody(HttpResponseData responseData) { // If the response is a redirect, retrieving the body will throw an error in CDP. if (responseData.StatusCode < 300 || responseData.StatusCode > 399) { var bodyResponse = await fetch.GetResponseBody(new Fetch.GetResponseBodyCommandSettings() { RequestId = responseData.RequestId }); if (bodyResponse.Base64Encoded) { responseData.Body = Encoding.UTF8.GetString(Convert.FromBase64String(bodyResponse.Body)); } else { responseData.Body = bodyResponse.Body; } } }