diff options
author | Martin Baulig <mabaul@microsoft.com> | 2020-04-16 21:34:26 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-16 21:34:26 +0300 |
commit | 60e12907d2bc8908c77754573b8a3364a6bfee68 (patch) | |
tree | 6a53e562adcfacbd2e259870514322871e7aab63 | |
parent | 1e3bb2b2f5573401c6428b865fbf7e6ca882c722 (diff) |
[System.Net.Http]: Disable exception filters on watchOS. (#398)
7 files changed, 158 insertions, 0 deletions
diff --git a/src/System.Net.Http/src/System/Net/Http/HttpContent.cs b/src/System.Net.Http/src/System/Net/Http/HttpContent.cs index 740347a083..fe424798d4 100644 --- a/src/System.Net.Http/src/System/Net/Http/HttpContent.cs +++ b/src/System.Net.Http/src/System/Net/Http/HttpContent.cs @@ -337,10 +337,21 @@ namespace System.Net.Http return CopyToAsyncCore(new ValueTask(task)); } } +#if MONOTOUCH_WATCH + catch (Exception e) + { + if (StreamCopyExceptionNeedsWrapping(e)) + { + return Task.FromException(GetStreamCopyException(e)); + } + throw; + } +#else catch (Exception e) when (StreamCopyExceptionNeedsWrapping(e)) { return Task.FromException(GetStreamCopyException(e)); } +#endif } private static async Task CopyToAsyncCore(ValueTask copyTask) @@ -349,10 +360,21 @@ namespace System.Net.Http { await copyTask.ConfigureAwait(false); } +#if MONOTOUCH_WATCH + catch (Exception e) + { + if (StreamCopyExceptionNeedsWrapping(e)) + { + throw GetStreamCopyException(e); + } + throw; + } +#else catch (Exception e) when (StreamCopyExceptionNeedsWrapping(e)) { throw GetStreamCopyException(e); } +#endif } public Task CopyToAsync(Stream stream) @@ -403,10 +425,21 @@ namespace System.Net.Http CheckTaskNotNull(task); return LoadIntoBufferAsyncCore(task, tempBuffer); } +#if MONOTOUCH_WATCH + catch (Exception e) + { + if (StreamCopyExceptionNeedsWrapping(e)) + { + return Task.FromException(GetStreamCopyException(e)); + } + throw; + } +#else catch (Exception e) when (StreamCopyExceptionNeedsWrapping(e)) { return Task.FromException(GetStreamCopyException(e)); } +#endif // other synchronous exceptions from SerializeToStreamAsync/CheckTaskNotNull will propagate } diff --git a/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ChunkedEncodingReadStream.cs b/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ChunkedEncodingReadStream.cs index fdf7d48e56..d10a2233dc 100644 --- a/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ChunkedEncodingReadStream.cs +++ b/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ChunkedEncodingReadStream.cs @@ -115,10 +115,21 @@ namespace System.Net.Http } } } +#if MONOTOUCH_WATCH + catch (Exception exc) + { + if (CancellationHelper.ShouldWrapInOperationCanceledException(exc, cancellationToken)) + { + throw CancellationHelper.CreateOperationCanceledException(exc, cancellationToken); + } + throw; + } +#else catch (Exception exc) when (CancellationHelper.ShouldWrapInOperationCanceledException(exc, cancellationToken)) { throw CancellationHelper.CreateOperationCanceledException(exc, cancellationToken); } +#endif finally { ctr.Dispose(); @@ -161,10 +172,21 @@ namespace System.Net.Http await _connection.FillAsync().ConfigureAwait(false); } } +#if MONOTOUCH_WATCH + catch (Exception exc) + { + if (CancellationHelper.ShouldWrapInOperationCanceledException(exc, cancellationToken)) + { + throw CancellationHelper.CreateOperationCanceledException(exc, cancellationToken); + } + throw; + } +#else catch (Exception exc) when (CancellationHelper.ShouldWrapInOperationCanceledException(exc, cancellationToken)) { throw CancellationHelper.CreateOperationCanceledException(exc, cancellationToken); } +#endif finally { ctr.Dispose(); diff --git a/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectionCloseReadStream.cs b/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectionCloseReadStream.cs index 1506cdf2b8..7471a07ce4 100644 --- a/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectionCloseReadStream.cs +++ b/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectionCloseReadStream.cs @@ -39,10 +39,21 @@ namespace System.Net.Http { bytesRead = await readTask.ConfigureAwait(false); } +#if MONOTOUCH_WATCH + catch (Exception exc) + { + if (CancellationHelper.ShouldWrapInOperationCanceledException(exc, cancellationToken)) + { + throw CancellationHelper.CreateOperationCanceledException(exc, cancellationToken); + } + throw; + } +#else catch (Exception exc) when (CancellationHelper.ShouldWrapInOperationCanceledException(exc, cancellationToken)) { throw CancellationHelper.CreateOperationCanceledException(exc, cancellationToken); } +#endif finally { ctr.Dispose(); @@ -100,10 +111,21 @@ namespace System.Net.Http { await copyTask.ConfigureAwait(false); } +#if MONOTOUCH_WATCH + catch (Exception exc) + { + if (CancellationHelper.ShouldWrapInOperationCanceledException(exc, cancellationToken)) + { + throw CancellationHelper.CreateOperationCanceledException(exc, cancellationToken); + } + throw; + } +#else catch (Exception exc) when (CancellationHelper.ShouldWrapInOperationCanceledException(exc, cancellationToken)) { throw CancellationHelper.CreateOperationCanceledException(exc, cancellationToken); } +#endif finally { ctr.Dispose(); diff --git a/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ContentLengthReadStream.cs b/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ContentLengthReadStream.cs index cbf51b0424..9c90a419f4 100644 --- a/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ContentLengthReadStream.cs +++ b/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ContentLengthReadStream.cs @@ -51,10 +51,21 @@ namespace System.Net.Http { bytesRead = await readTask.ConfigureAwait(false); } +#if MONOTOUCH_WATCH + catch (Exception exc) + { + if (CancellationHelper.ShouldWrapInOperationCanceledException(exc, cancellationToken)) + { + throw CancellationHelper.CreateOperationCanceledException(exc, cancellationToken); + } + throw; + } +#else catch (Exception exc) when (CancellationHelper.ShouldWrapInOperationCanceledException(exc, cancellationToken)) { throw CancellationHelper.CreateOperationCanceledException(exc, cancellationToken); } +#endif finally { ctr.Dispose(); @@ -115,10 +126,21 @@ namespace System.Net.Http { await copyTask.ConfigureAwait(false); } +#if MONOTOUCH_WATCH + catch (Exception exc) + { + if (CancellationHelper.ShouldWrapInOperationCanceledException(exc, cancellationToken)) + { + throw CancellationHelper.CreateOperationCanceledException(exc, cancellationToken); + } + throw; + } +#else catch (Exception exc) when (CancellationHelper.ShouldWrapInOperationCanceledException(exc, cancellationToken)) { throw CancellationHelper.CreateOperationCanceledException(exc, cancellationToken); } +#endif finally { ctr.Dispose(); diff --git a/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnection.cs b/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnection.cs index e7ffaef7bc..6374d98241 100644 --- a/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnection.cs +++ b/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnection.cs @@ -158,11 +158,23 @@ namespace System.Net.Http { return _socket.Poll(0, SelectMode.SelectRead); } +#if MONOTOUCH_WATCH + catch (Exception exc) + { + if (e is SocketException || e is ObjectDisposedException) + { + // Poll can throw when used on a closed socket. + return true; + } + throw; + } +#else catch (Exception e) when (e is SocketException || e is ObjectDisposedException) { // Poll can throw when used on a closed socket. return true; } +#endif } else { diff --git a/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs b/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs index 13bcd87f19..c2df0a38e4 100644 --- a/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs +++ b/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs @@ -295,10 +295,24 @@ namespace System.Net.Http { return await SendWithNtConnectionAuthAsync((HttpConnection)connection, request, doRequestAuth, cancellationToken).ConfigureAwait(false); } +#if MONOTOUCH_WATCH + catch (HttpRequestException e) + { + if (!isNewConnection && e.InnerException is IOException && connection.CanRetry) + { + // Eat exception and try again. + } + else + { + throw; + } + } +#else catch (HttpRequestException e) when (!isNewConnection && e.InnerException is IOException && connection.CanRetry) { // Eat exception and try again. } +#endif finally { connection.Release(); diff --git a/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/RawConnectionStream.cs b/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/RawConnectionStream.cs index 6eba9babd3..b32ae62834 100644 --- a/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/RawConnectionStream.cs +++ b/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/RawConnectionStream.cs @@ -39,10 +39,21 @@ namespace System.Net.Http { bytesRead = await readTask.ConfigureAwait(false); } +#if MONOTOUCH_WATCH + catch (Exception exc) + { + if (CancellationHelper.ShouldWrapInOperationCanceledException(exc, cancellationToken)) + { + throw CancellationHelper.CreateOperationCanceledException(exc, cancellationToken); + } + throw; + } +#else catch (Exception exc) when (CancellationHelper.ShouldWrapInOperationCanceledException(exc, cancellationToken)) { throw CancellationHelper.CreateOperationCanceledException(exc, cancellationToken); } +#endif finally { ctr.Dispose(); @@ -95,10 +106,21 @@ namespace System.Net.Http { await copyTask.ConfigureAwait(false); } +#if MONOTOUCH_WATCH + catch (Exception exc) + { + if (CancellationHelper.ShouldWrapInOperationCanceledException(exc, cancellationToken)) + { + throw CancellationHelper.CreateOperationCanceledException(exc, cancellationToken); + } + throw; + } +#else catch (Exception exc) when (CancellationHelper.ShouldWrapInOperationCanceledException(exc, cancellationToken)) { throw CancellationHelper.CreateOperationCanceledException(exc, cancellationToken); } +#endif finally { ctr.Dispose(); @@ -168,10 +190,21 @@ namespace System.Net.Http { await task.ConfigureAwait(false); } +#if MONOTOUCH_WATCH + catch (Exception exc) + { + if (CancellationHelper.ShouldWrapInOperationCanceledException(exc, cancellationToken)) + { + throw CancellationHelper.CreateOperationCanceledException(exc, cancellationToken); + } + throw; + } +#else catch (Exception exc) when (CancellationHelper.ShouldWrapInOperationCanceledException(exc, cancellationToken)) { throw CancellationHelper.CreateOperationCanceledException(exc, cancellationToken); } +#endif finally { ctr.Dispose(); |