@@ -277,8 +277,12 @@ await Task.WhenAny(sendRequestTask, readResponseTask).ConfigureAwait(false) == s
277
277
}
278
278
catch ( QuicException ex ) when ( ex . QuicError == QuicError . OperationAborted && _connection . AbortException != null )
279
279
{
280
- // we close the connection, propagate the AbortException
281
- throw new HttpRequestException ( HttpRequestError . Unknown , SR . net_http_client_execution_error , _connection . AbortException ) ;
280
+ // we closed the connection already, propagate the AbortException
281
+ HttpRequestError httpRequestError = _connection . AbortException is HttpProtocolException
282
+ ? HttpRequestError . HttpProtocolError
283
+ : HttpRequestError . Unknown ;
284
+
285
+ throw new HttpRequestException ( httpRequestError , SR . net_http_client_execution_error , _connection . AbortException ) ;
282
286
}
283
287
// It is possible for user's Content code to throw an unexpected OperationCanceledException.
284
288
catch ( OperationCanceledException ex ) when ( ex . CancellationToken == _requestBodyCancellationSource . Token || ex . CancellationToken == cancellationToken )
@@ -300,13 +304,26 @@ await Task.WhenAny(sendRequestTask, readResponseTask).ConfigureAwait(false) == s
300
304
_connection . Abort ( ex ) ;
301
305
throw new HttpRequestException ( ex . HttpRequestError , SR . net_http_client_execution_error , ex ) ;
302
306
}
307
+ catch ( QPackDecodingException ex )
308
+ {
309
+ Exception abortException = _connection . Abort ( HttpProtocolException . CreateHttp3ConnectionException ( Http3ErrorCode . QPackDecompressionFailed ) ) ;
310
+ throw new HttpRequestException ( HttpRequestError . InvalidResponse , SR . net_http_invalid_response , ex ) ;
311
+ }
312
+ catch ( QPackEncodingException ex )
313
+ {
314
+ _stream . Abort ( QuicAbortDirection . Write , ( long ) Http3ErrorCode . InternalError ) ;
315
+ throw new HttpRequestException ( HttpRequestError . Unknown , SR . net_http_client_execution_error , ex ) ;
316
+ }
303
317
catch ( Exception ex )
304
318
{
305
319
_stream . Abort ( QuicAbortDirection . Write , ( long ) Http3ErrorCode . InternalError ) ;
306
320
if ( ex is HttpRequestException )
307
321
{
308
322
throw ;
309
323
}
324
+
325
+ // all exceptions should be already handled above
326
+ Debug . Fail ( $ "Unexpected exception type in Http3RequestStream.SendAsync: { ex } ") ;
310
327
throw new HttpRequestException ( HttpRequestError . Unknown , SR . net_http_client_execution_error , ex ) ;
311
328
}
312
329
finally
@@ -1253,6 +1270,13 @@ private void HandleReadResponseContentException(Exception ex, CancellationToken
1253
1270
_connection . Abort ( exception ) ;
1254
1271
throw exception ;
1255
1272
1273
+ case QuicException e when ( e . QuicError == QuicError . OperationAborted && _connection . AbortException != null ) :
1274
+ // we closed the connection already, propagate the AbortException
1275
+ HttpRequestError httpRequestError = _connection . AbortException is HttpProtocolException
1276
+ ? HttpRequestError . HttpProtocolError
1277
+ : HttpRequestError . Unknown ;
1278
+ throw new HttpRequestException ( httpRequestError , SR . net_http_client_execution_error , _connection . AbortException ) ;
1279
+
1256
1280
case HttpIOException :
1257
1281
_connection . Abort ( ex ) ;
1258
1282
ExceptionDispatchInfo . Throw ( ex ) ; // Rethrow.
0 commit comments