// Token: 0x0600014A RID: 330 RVA: 0x00007AA4 File Offset: 0x00005CA4 private void OnReadMoreResponse(IAsyncResult asyncResult) { lock (this.syncRoot) { if (this.ShouldCancelCallback()) { NetworkConnection networkConnection = this.ExtractNetworkConnectionFrom(asyncResult); byte[] data; int offset; int num; object obj2; networkConnection.EndRead(asyncResult, out data, out offset, out num, out obj2); } else { base.CheckDisposed(); AsyncResult <ImapConnectionContext, ImapResultData> asyncResult2 = (AsyncResult <ImapConnectionContext, ImapResultData>)asyncResult.AsyncState; ImapResponse imapResponse = this.currentResponse; byte[] data; int offset; int num; object obj2; this.networkConnection.EndRead(asyncResult, out data, out offset, out num, out obj2); if (obj2 != null) { ImapNetworkFacade.HandleError(obj2, asyncResult2); } else if (this.cancellationRequested) { this.HandleCancellation(asyncResult2); } else { ExTraceGlobals.FaultInjectionTracer.TraceTest(2674273597U); this.totalBytesReceived += (long)num; DownloadCompleteEventArgs eventArgs = new DownloadCompleteEventArgs((long)num, 0L); asyncResult2.State.ActivatePerfDownloadEvent(asyncResult2.State, eventArgs); if (this.totalBytesReceived > this.connectionParameters.MaxBytesToTransfer) { ImapNetworkFacade.HandleError(ImapNetworkFacade.MaxBytesReceivedExceeded(), asyncResult2); } else { int num2 = imapResponse.AddData(data, offset, num); int num3 = num - num2; this.Log.Assert(num3 >= 0, "The unconsumed bytes must be non-negative.", new object[0]); if (num3 > 0) { this.networkConnection.PutBackReceivedBytes(num3); } if (imapResponse.IsComplete) { ImapNetworkFacade.CountCommand(asyncResult2, true); asyncResult2.State.Log.Debug("Command complete: [{0}]. Status = {1}", new object[] { this.currentCommand.ToPiiCleanString(), imapResponse.Status }); this.currentResultData.Status = imapResponse.Status; if (asyncResult.CompletedSynchronously) { asyncResult2.SetCompletedSynchronously(); } if (imapResponse.Status == ImapStatus.No || imapResponse.Status == ImapStatus.Bad || imapResponse.Status == ImapStatus.Bye) { this.LogFailureDetails(this.currentCommand, imapResponse); asyncResult2.ProcessCompleted(this.currentResultData); } else if (imapResponse.Status != ImapStatus.Ok) { this.LogFailureDetails(this.currentCommand, imapResponse); asyncResult2.ProcessCompleted(this.BuildAndLogUnknownCommandFailureException(asyncResult2.State)); } else { if (!imapResponse.TryParseIntoResult(this.currentCommand, ref this.currentResultData)) { if (this.currentResultData.FailureException == null) { if (this.currentResultData.MessageStream != null) { this.totalMessagesReceived += 1UL; } asyncResult2.ProcessCompleted(this.currentResultData, this.BuildAndLogUnknownParseFailureException(asyncResult2.State)); return; } ImapUtilities.LogExceptionDetails(asyncResult2.State.Log, this.currentCommand, this.currentResultData.FailureException); this.LogFailureDetails(this.currentCommand, this.currentResponse); } else { asyncResult2.State.Log.Debug("Parsed server response succesfully.", new object[0]); } asyncResult2.ProcessCompleted(this.currentResultData); } } else if (imapResponse.IsWaitingForLiteral) { Exception ex = null; Stream commandParameterStream = this.currentCommand.GetCommandParameterStream(this.serverParameters.Server, imapResponse.GetLastResponseLine(), out ex); if (ex != null) { if (commandParameterStream != null) { commandParameterStream.Close(); } ImapNetworkFacade.CountCommand(asyncResult2, false); asyncResult2.ProcessCompleted(ex); } else if (commandParameterStream == null) { ImapNetworkFacade.CountCommand(asyncResult2, false); asyncResult2.ProcessCompleted(this.BuildAndLogUnexpectedLiteralRequestException(asyncResult2.State)); } else { this.totalBytesSent += commandParameterStream.Length; if (this.totalBytesSent > this.connectionParameters.MaxBytesToTransfer) { ImapNetworkFacade.HandleError(ImapNetworkFacade.MaxBytesSentExceeded(), asyncResult2); } else { eventArgs = new DownloadCompleteEventArgs(0L, commandParameterStream.Length); asyncResult2.State.ActivatePerfDownloadEvent(asyncResult2.State, eventArgs); asyncResult2.State.Log.Debug("Begin writing literal stream.", new object[0]); asyncResult2.PendingAsyncResult = this.networkConnection.BeginWrite(commandParameterStream, new AsyncCallback(this.OnEndWriteLiteral), asyncResult2); } } } else if (imapResponse.TotalLiteralBytesExpected > 0 && this.totalBytesReceived + (long)imapResponse.LiteralBytesRemaining > this.connectionParameters.MaxBytesToTransfer) { this.totalBytesReceived += (long)imapResponse.LiteralBytesRemaining; ImapNetworkFacade.HandleError(ImapNetworkFacade.MaxBytesReceivedExceeded(), asyncResult2); } else { asyncResult2.PendingAsyncResult = this.BeginNetworkRead(asyncResult2, new AsyncCallback(this.OnReadMoreResponse)); } } } } } }
// Token: 0x06000147 RID: 327 RVA: 0x000075E4 File Offset: 0x000057E4 private void OnReadAndDiscardLine(IAsyncResult asyncResult) { lock (this.syncRoot) { if (this.ShouldCancelCallback()) { NetworkConnection networkConnection = this.ExtractNetworkConnectionFrom(asyncResult); byte[] data; int offset; int num; object obj2; networkConnection.EndRead(asyncResult, out data, out offset, out num, out obj2); } else { base.CheckDisposed(); AsyncResult <ImapConnectionContext, ImapResultData> asyncResult2 = (AsyncResult <ImapConnectionContext, ImapResultData>)asyncResult.AsyncState; ImapResponse imapResponse = this.currentResponse; byte[] data; int offset; int num; object obj2; this.networkConnection.EndRead(asyncResult, out data, out offset, out num, out obj2); if (obj2 != null) { ImapNetworkFacade.HandleError(obj2, asyncResult2); } else if (this.cancellationRequested) { this.HandleCancellation(asyncResult2); } else { ExTraceGlobals.FaultInjectionTracer.TraceTest(4284886333U); this.totalBytesReceived += (long)num; DownloadCompleteEventArgs eventArgs = new DownloadCompleteEventArgs((long)num, 0L); asyncResult2.State.ActivatePerfDownloadEvent(asyncResult2.State, eventArgs); if (this.totalBytesReceived > this.connectionParameters.MaxBytesToTransfer) { ImapNetworkFacade.HandleError(ImapNetworkFacade.MaxBytesReceivedExceeded(), asyncResult2); } else { int num2 = imapResponse.AddData(data, offset, num); int num3 = num - num2; this.Log.Assert(num3 >= 0, "The unconsumed bytes must be non-negative.", new object[0]); if (num3 > 0) { this.networkConnection.PutBackReceivedBytes(num3); } if (imapResponse.IsComplete) { this.currentResultData.Clear(); this.currentResultData.Status = imapResponse.Status; if (asyncResult.CompletedSynchronously) { asyncResult2.SetCompletedSynchronously(); } asyncResult2.State.Log.Assert(this.currentCommand == null, "this.currentCommand is expected to be null", new object[0]); if (imapResponse.Status == ImapStatus.No || imapResponse.Status == ImapStatus.Bad || imapResponse.Status == ImapStatus.Bye) { this.LogFailureDetails("Connecting", imapResponse); asyncResult2.ProcessCompleted(this.currentResultData); } else { asyncResult2.State.Log.Assert(imapResponse.ResponseLines != null && imapResponse.ResponseLines.Count > 0, "ResponseLines was null or had no content", new object[0]); if (imapResponse.Status != ImapStatus.Ok) { asyncResult2.ProcessCompleted(this.BuildAndLogUnknownCommandFailureException(asyncResult2.State, "Connecting")); } else { asyncResult2.ProcessCompleted(this.currentResultData); } } } else { asyncResult2.PendingAsyncResult = this.BeginNetworkRead(asyncResult2, new AsyncCallback(this.OnReadAndDiscardLine)); } } } } } }