public override int EndRead(IAsyncResult asyncResult) { if (Logging.On) { Logging.Enter(Logging.HttpListener, this, "EndRead", ""); } GlobalLog.Print("HttpRequestStream#" + ValidationHelper.HashString(this) + "::EndRead() asyncResult#" + ValidationHelper.HashString(asyncResult)); if (asyncResult == null) { throw new ArgumentNullException("asyncResult"); } HttpRequestStreamAsyncResult castedAsyncResult = asyncResult as HttpRequestStreamAsyncResult; if (castedAsyncResult == null || castedAsyncResult.AsyncObject != this) { throw new ArgumentException(SR.GetString(SR.net_io_invalidasyncresult), "asyncResult"); } if (castedAsyncResult.EndCalled) { throw new InvalidOperationException(SR.GetString(SR.net_io_invalidendcall, "EndRead")); } castedAsyncResult.EndCalled = true; // wait & then check for errors object returnValue = castedAsyncResult.InternalWaitForCompletion(); Exception exception = returnValue as Exception; if (exception != null) { GlobalLog.Print("HttpRequestStream#" + ValidationHelper.HashString(this) + "::EndRead() rethrowing exception:" + exception); if (Logging.On) { Logging.Exception(Logging.HttpListener, this, "EndRead", exception); } throw exception; } // uint dataRead = (uint)returnValue; UpdateAfterRead((uint)castedAsyncResult.ErrorCode, dataRead); GlobalLog.Print("HttpRequestStream#" + ValidationHelper.HashString(this) + "::EndRead() returning returnValue:" + ValidationHelper.ToString(returnValue)); if (Logging.On) { Logging.Exit(Logging.HttpListener, this, "EndRead", ""); } return((int)dataRead + (int)castedAsyncResult.m_dataAlreadyRead); }
public override int EndRead(IAsyncResult asyncResult) { if (NetEventSource.IsEnabled) { NetEventSource.Enter(this); NetEventSource.Info(this, $"asyncResult: {asyncResult}"); } if (asyncResult == null) { throw new ArgumentNullException(nameof(asyncResult)); } HttpRequestStreamAsyncResult castedAsyncResult = asyncResult as HttpRequestStreamAsyncResult; if (castedAsyncResult == null || castedAsyncResult.AsyncObject != this) { throw new ArgumentException(SR.net_io_invalidasyncresult, nameof(asyncResult)); } if (castedAsyncResult.EndCalled) { throw new InvalidOperationException(SR.Format(SR.net_io_invalidendcall, nameof(EndRead))); } castedAsyncResult.EndCalled = true; // wait & then check for errors object returnValue = castedAsyncResult.InternalWaitForCompletion(); Exception exception = returnValue as Exception; if (exception != null) { if (NetEventSource.IsEnabled) { NetEventSource.Info(this, "Rethrowing exception:" + exception); NetEventSource.Error(this, exception.ToString()); } throw exception; } uint dataRead = (uint)returnValue; UpdateAfterRead((uint)castedAsyncResult.ErrorCode, dataRead); if (NetEventSource.IsEnabled) { NetEventSource.Info(this, $"returnValue:{returnValue}"); NetEventSource.Exit(this); } return((int)dataRead + (int)castedAsyncResult._dataAlreadyRead); }
public override int EndRead(IAsyncResult asyncResult) { if (Logging.On) { Logging.Enter(Logging.HttpListener, this, "EndRead", ""); } if (asyncResult == null) { throw new ArgumentNullException("asyncResult"); } HttpRequestStreamAsyncResult result = asyncResult as HttpRequestStreamAsyncResult; if ((result == null) || (result.AsyncObject != this)) { throw new ArgumentException(SR.GetString("net_io_invalidasyncresult"), "asyncResult"); } if (result.EndCalled) { throw new InvalidOperationException(SR.GetString("net_io_invalidendcall", new object[] { "EndRead" })); } result.EndCalled = true; object obj2 = result.InternalWaitForCompletion(); Exception e = obj2 as Exception; if (e != null) { if (Logging.On) { Logging.Exception(Logging.HttpListener, this, "EndRead", e); } throw e; } uint dataRead = (uint)obj2; this.UpdateAfterRead((uint)result.ErrorCode, dataRead); if (Logging.On) { Logging.Exit(Logging.HttpListener, this, "EndRead", ""); } return((int)(dataRead + result.m_dataAlreadyRead)); }