#56 - Make Request & Response Stream throw IOException.

This commit is contained in:
Chris Ross 2014-09-12 15:38:02 -07:00
parent 736fc684e6
commit 0139bea6d2
4 changed files with 14 additions and 13 deletions

View File

@ -178,7 +178,7 @@ namespace Microsoft.Net.Http.Server
} }
if (statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS && statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_HANDLE_EOF) if (statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS && statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_HANDLE_EOF)
{ {
Exception exception = new WebListenerException((int)statusCode); Exception exception = new IOException(string.Empty, new WebListenerException((int)statusCode));
LogHelper.LogException(_requestContext.Logger, "Read", exception); LogHelper.LogException(_requestContext.Logger, "Read", exception);
Abort(); Abort();
throw exception; throw exception;
@ -275,7 +275,7 @@ namespace Microsoft.Net.Http.Server
} }
else else
{ {
Exception exception = new WebListenerException((int)statusCode); Exception exception = new IOException(string.Empty, new WebListenerException((int)statusCode));
LogHelper.LogException(_requestContext.Logger, "BeginRead", exception); LogHelper.LogException(_requestContext.Logger, "BeginRead", exception);
Abort(); Abort();
throw exception; throw exception;
@ -401,7 +401,7 @@ namespace Microsoft.Net.Http.Server
} }
else else
{ {
Exception exception = new WebListenerException((int)statusCode); Exception exception = new IOException(string.Empty, new WebListenerException((int)statusCode));
LogHelper.LogException(_requestContext.Logger, "ReadAsync", exception); LogHelper.LogException(_requestContext.Logger, "ReadAsync", exception);
Abort(); Abort();
throw exception; throw exception;

View File

@ -23,6 +23,7 @@
using System; using System;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -109,7 +110,7 @@ namespace Microsoft.Net.Http.Server
{ {
if (errorCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS && errorCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_HANDLE_EOF) if (errorCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS && errorCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_HANDLE_EOF)
{ {
asyncResult.Fail(new WebListenerException((int)errorCode)); asyncResult.Fail(new IOException(string.Empty, new WebListenerException((int)errorCode)));
} }
else else
{ {

View File

@ -113,7 +113,7 @@ namespace Microsoft.Net.Http.Server
if (statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS && statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_HANDLE_EOF) if (statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS && statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_HANDLE_EOF)
{ {
throw new WebListenerException((int)statusCode); throw new IOException(string.Empty, new WebListenerException((int)statusCode));
} }
} }
catch (Exception e) catch (Exception e)
@ -164,7 +164,7 @@ namespace Microsoft.Net.Http.Server
} }
else if (statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS && statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_IO_PENDING) else if (statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS && statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_IO_PENDING)
{ {
throw new WebListenerException((int)statusCode); throw new IOException(string.Empty, new WebListenerException((int)statusCode));
} }
} }
catch (Exception e) catch (Exception e)
@ -351,7 +351,7 @@ namespace Microsoft.Net.Http.Server
if (statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS && statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_HANDLE_EOF) if (statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS && statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_HANDLE_EOF)
{ {
Exception exception = new WebListenerException((int)statusCode); Exception exception = new IOException(string.Empty, new WebListenerException((int)statusCode));
LogHelper.LogException(_requestContext.Logger, "Write", exception); LogHelper.LogException(_requestContext.Logger, "Write", exception);
Abort(); Abort();
throw exception; throw exception;
@ -444,7 +444,7 @@ namespace Microsoft.Net.Http.Server
} }
else else
{ {
Exception exception = new WebListenerException((int)statusCode); Exception exception = new IOException(string.Empty, new WebListenerException((int)statusCode));
LogHelper.LogException(_requestContext.Logger, "BeginWrite", exception); LogHelper.LogException(_requestContext.Logger, "BeginWrite", exception);
Abort(); Abort();
throw exception; throw exception;
@ -589,7 +589,7 @@ namespace Microsoft.Net.Http.Server
} }
else else
{ {
Exception exception = new WebListenerException((int)statusCode); Exception exception = new IOException(string.Empty, new WebListenerException((int)statusCode));
LogHelper.LogException(_requestContext.Logger, "WriteAsync", exception); LogHelper.LogException(_requestContext.Logger, "WriteAsync", exception);
Abort(); Abort();
throw exception; throw exception;
@ -602,7 +602,7 @@ namespace Microsoft.Net.Http.Server
asyncResult.IOCompleted(statusCode, bytesSent); asyncResult.IOCompleted(statusCode, bytesSent);
} }
// Last write, cache it for special cancelation handling. // Last write, cache it for special cancellation handling.
if ((flags & UnsafeNclNativeMethods.HttpApi.HTTP_FLAGS.HTTP_SEND_RESPONSE_FLAG_MORE_DATA) == 0) if ((flags & UnsafeNclNativeMethods.HttpApi.HTTP_FLAGS.HTTP_SEND_RESPONSE_FLAG_MORE_DATA) == 0)
{ {
_lastWrite = asyncResult; _lastWrite = asyncResult;
@ -710,7 +710,7 @@ namespace Microsoft.Net.Http.Server
} }
else else
{ {
Exception exception = new WebListenerException((int)statusCode); Exception exception = new IOException(string.Empty, new WebListenerException((int)statusCode));
LogHelper.LogException(_requestContext.Logger, "SendFileAsync", exception); LogHelper.LogException(_requestContext.Logger, "SendFileAsync", exception);
Abort(); Abort();
throw exception; throw exception;
@ -829,7 +829,7 @@ namespace Microsoft.Net.Http.Server
// Don't throw for disconnects, we were already finished with the response. // Don't throw for disconnects, we were already finished with the response.
&& statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_CONNECTION_INVALID) && statusCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_CONNECTION_INVALID)
{ {
Exception exception = new WebListenerException((int)statusCode); Exception exception = new IOException(string.Empty, new WebListenerException((int)statusCode));
LogHelper.LogException(_requestContext.Logger, "Dispose", exception); LogHelper.LogException(_requestContext.Logger, "Dispose", exception);
_requestContext.Abort(); _requestContext.Abort();
throw exception; throw exception;

View File

@ -291,7 +291,7 @@ namespace Microsoft.Net.Http.Server
{ {
if (errorCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS && errorCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_HANDLE_EOF) if (errorCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS && errorCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_HANDLE_EOF)
{ {
asyncResult.Fail(new WebListenerException((int)errorCode)); asyncResult.Fail(new IOException(string.Empty, new WebListenerException((int)errorCode)));
} }
else else
{ {