File tree Expand file tree Collapse file tree 4 files changed +44
-28
lines changed
dotnet/src/webdriver/DevTools Expand file tree Collapse file tree 4 files changed +44
-28
lines changed Original file line number Diff line number Diff line change @@ -241,14 +241,18 @@ await fetch.ContinueWithAuth(new ContinueWithAuthCommandSettings()
241241 /// <returns>A task that represents the asynchronous operation.</returns>
242242 public override async Task AddResponseBody ( HttpResponseData responseData )
243243 {
244- var bodyResponse = await fetch . GetResponseBody ( new Fetch . GetResponseBodyCommandSettings ( ) { RequestId = responseData . RequestId } ) ;
245- if ( bodyResponse . Base64Encoded )
244+ // If the response is a redirect, retrieving the body will throw an error in CDP.
245+ if ( responseData . StatusCode < 300 || responseData . StatusCode > 399 )
246246 {
247- responseData . Body = Encoding . UTF8 . GetString ( Convert . FromBase64String ( bodyResponse . Body ) ) ;
248- }
249- else
250- {
251- responseData . Body = bodyResponse . Body ;
247+ var bodyResponse = await fetch . GetResponseBody ( new Fetch . GetResponseBodyCommandSettings ( ) { RequestId = responseData . RequestId } ) ;
248+ if ( bodyResponse . Base64Encoded )
249+ {
250+ responseData . Body = Encoding . UTF8 . GetString ( Convert . FromBase64String ( bodyResponse . Body ) ) ;
251+ }
252+ else
253+ {
254+ responseData . Body = bodyResponse . Body ;
255+ }
252256 }
253257 }
254258
Original file line number Diff line number Diff line change @@ -241,14 +241,18 @@ await fetch.ContinueWithAuth(new ContinueWithAuthCommandSettings()
241241 /// <returns>A task that represents the asynchronous operation.</returns>
242242 public override async Task AddResponseBody ( HttpResponseData responseData )
243243 {
244- var bodyResponse = await fetch . GetResponseBody ( new Fetch . GetResponseBodyCommandSettings ( ) { RequestId = responseData . RequestId } ) ;
245- if ( bodyResponse . Base64Encoded )
244+ // If the response is a redirect, retrieving the body will throw an error in CDP.
245+ if ( responseData . StatusCode < 300 || responseData . StatusCode > 399 )
246246 {
247- responseData . Body = Encoding . UTF8 . GetString ( Convert . FromBase64String ( bodyResponse . Body ) ) ;
248- }
249- else
250- {
251- responseData . Body = bodyResponse . Body ;
247+ var bodyResponse = await fetch . GetResponseBody ( new Fetch . GetResponseBodyCommandSettings ( ) { RequestId = responseData . RequestId } ) ;
248+ if ( bodyResponse . Base64Encoded )
249+ {
250+ responseData . Body = Encoding . UTF8 . GetString ( Convert . FromBase64String ( bodyResponse . Body ) ) ;
251+ }
252+ else
253+ {
254+ responseData . Body = bodyResponse . Body ;
255+ }
252256 }
253257 }
254258
Original file line number Diff line number Diff line change @@ -241,14 +241,18 @@ await fetch.ContinueWithAuth(new ContinueWithAuthCommandSettings()
241241 /// <returns>A task that represents the asynchronous operation.</returns>
242242 public override async Task AddResponseBody ( HttpResponseData responseData )
243243 {
244- var bodyResponse = await fetch . GetResponseBody ( new Fetch . GetResponseBodyCommandSettings ( ) { RequestId = responseData . RequestId } ) ;
245- if ( bodyResponse . Base64Encoded )
244+ // If the response is a redirect, retrieving the body will throw an error in CDP.
245+ if ( responseData . StatusCode < 300 || responseData . StatusCode > 399 )
246246 {
247- responseData . Body = Encoding . UTF8 . GetString ( Convert . FromBase64String ( bodyResponse . Body ) ) ;
248- }
249- else
250- {
251- responseData . Body = bodyResponse . Body ;
247+ var bodyResponse = await fetch . GetResponseBody ( new Fetch . GetResponseBodyCommandSettings ( ) { RequestId = responseData . RequestId } ) ;
248+ if ( bodyResponse . Base64Encoded )
249+ {
250+ responseData . Body = Encoding . UTF8 . GetString ( Convert . FromBase64String ( bodyResponse . Body ) ) ;
251+ }
252+ else
253+ {
254+ responseData . Body = bodyResponse . Body ;
255+ }
252256 }
253257 }
254258
Original file line number Diff line number Diff line change @@ -241,14 +241,18 @@ await fetch.ContinueWithAuth(new ContinueWithAuthCommandSettings()
241241 /// <returns>A task that represents the asynchronous operation.</returns>
242242 public override async Task AddResponseBody ( HttpResponseData responseData )
243243 {
244- var bodyResponse = await fetch . GetResponseBody ( new Fetch . GetResponseBodyCommandSettings ( ) { RequestId = responseData . RequestId } ) ;
245- if ( bodyResponse . Base64Encoded )
244+ // If the response is a redirect, retrieving the body will throw an error in CDP.
245+ if ( responseData . StatusCode < 300 || responseData . StatusCode > 399 )
246246 {
247- responseData . Body = Encoding . UTF8 . GetString ( Convert . FromBase64String ( bodyResponse . Body ) ) ;
248- }
249- else
250- {
251- responseData . Body = bodyResponse . Body ;
247+ var bodyResponse = await fetch . GetResponseBody ( new Fetch . GetResponseBodyCommandSettings ( ) { RequestId = responseData . RequestId } ) ;
248+ if ( bodyResponse . Base64Encoded )
249+ {
250+ responseData . Body = Encoding . UTF8 . GetString ( Convert . FromBase64String ( bodyResponse . Body ) ) ;
251+ }
252+ else
253+ {
254+ responseData . Body = bodyResponse . Body ;
255+ }
252256 }
253257 }
254258
You can’t perform that action at this time.
0 commit comments