From 42f97952448e6545d79b0bf65a51d268c646df60 Mon Sep 17 00:00:00 2001 From: "bienvenu%nventure.com" Date: Wed, 2 Mar 2005 01:12:35 +0000 Subject: [PATCH] fix 272988 handle dovecot imap server sending size after message headers when downloading headers, sr=mscott --- .../imap/src/nsImapServerResponseParser.cpp | 22 +++++++++++++++++-- .../imap/src/nsImapServerResponseParser.h | 2 ++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/mailnews/imap/src/nsImapServerResponseParser.cpp b/mailnews/imap/src/nsImapServerResponseParser.cpp index b16c62b818fb..5d36be439b60 100644 --- a/mailnews/imap/src/nsImapServerResponseParser.cpp +++ b/mailnews/imap/src/nsImapServerResponseParser.cpp @@ -96,6 +96,7 @@ nsImapServerResponseParser::nsImapServerResponseParser(nsImapProtocol &imapProto fStatusRecentMessages = 0; fStatusNextUID = nsMsgKey_None; fStatusExistingMessages = 0; + fReceivedHeaderOrSizeForUID = nsMsgKey_None; } nsImapServerResponseParser::~nsImapServerResponseParser() @@ -183,6 +184,7 @@ void nsImapServerResponseParser::InitializeState() fProcessingTaggedResponse = PR_FALSE; fCurrentCommandFailed = PR_FALSE; fNumberOfRecentMessages = 0; + fReceivedHeaderOrSizeForUID = nsMsgKey_None; } void nsImapServerResponseParser::ParseIMAPServerResponse(const char *currentCommand, PRBool aIgnoreBadAndNOResponses) @@ -1202,8 +1204,16 @@ void nsImapServerResponseParser::msg_fetch() AdvanceToNextToken(); if (ContinueParse()) { + PRBool sendEndMsgDownload = (GetDownloadingHeaders() + && fReceivedHeaderOrSizeForUID == CurrentResponseUID()); fSizeOfMostRecentMessage = atoi(fNextToken); - + fReceivedHeaderOrSizeForUID = CurrentResponseUID(); + if (sendEndMsgDownload) + { + fServerConnection.NormalMessageEndDownload(); + fReceivedHeaderOrSizeForUID = nsMsgKey_None; + } + // if we are in the process of fetching everything RFC822 then we should // turn around and force the total download size to be set to this value. // this helps if the server gaves us a bogus size for the message in response to the @@ -2050,7 +2060,15 @@ void nsImapServerResponseParser::msg_fetch_content(PRBool chunk, PRInt32 origin, { // complete the message download if (ContinueParse()) - fServerConnection.NormalMessageEndDownload(); + { + if (fReceivedHeaderOrSizeForUID == CurrentResponseUID()) + { + fServerConnection.NormalMessageEndDownload(); + fReceivedHeaderOrSizeForUID = nsMsgKey_None; + } + else + fReceivedHeaderOrSizeForUID = CurrentResponseUID(); + } else fServerConnection.AbortMessageDownLoad(); } diff --git a/mailnews/imap/src/nsImapServerResponseParser.h b/mailnews/imap/src/nsImapServerResponseParser.h index c04613384928..b80140a187c2 100644 --- a/mailnews/imap/src/nsImapServerResponseParser.h +++ b/mailnews/imap/src/nsImapServerResponseParser.h @@ -238,6 +238,8 @@ private: PRInt32 fNumberOfRecentMessages; PRUint32 fCurrentResponseUID; PRUint32 fHighestRecordedUID; + // used to handle server that sends msg size after headers + PRUint32 fReceivedHeaderOrSizeForUID; PRInt32 fSizeOfMostRecentMessage; PRInt32 fTotalDownloadSize;