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()
241
241
/// <returns>A task that represents the asynchronous operation.</returns>
242
242
public override async Task AddResponseBody ( HttpResponseData responseData )
243
243
{
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 )
246
246
{
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
+ }
252
256
}
253
257
}
254
258
Original file line number Diff line number Diff line change @@ -241,14 +241,18 @@ await fetch.ContinueWithAuth(new ContinueWithAuthCommandSettings()
241
241
/// <returns>A task that represents the asynchronous operation.</returns>
242
242
public override async Task AddResponseBody ( HttpResponseData responseData )
243
243
{
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 )
246
246
{
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
+ }
252
256
}
253
257
}
254
258
Original file line number Diff line number Diff line change @@ -241,14 +241,18 @@ await fetch.ContinueWithAuth(new ContinueWithAuthCommandSettings()
241
241
/// <returns>A task that represents the asynchronous operation.</returns>
242
242
public override async Task AddResponseBody ( HttpResponseData responseData )
243
243
{
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 )
246
246
{
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
+ }
252
256
}
253
257
}
254
258
Original file line number Diff line number Diff line change @@ -241,14 +241,18 @@ await fetch.ContinueWithAuth(new ContinueWithAuthCommandSettings()
241
241
/// <returns>A task that represents the asynchronous operation.</returns>
242
242
public override async Task AddResponseBody ( HttpResponseData responseData )
243
243
{
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 )
246
246
{
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
+ }
252
256
}
253
257
}
254
258
You can’t perform that action at this time.
0 commit comments