From 99224547e3b98042aea13c48e67ebb0daf8e9e20 Mon Sep 17 00:00:00 2001 From: Zhang Lubo Date: Thu, 17 Dec 2015 15:15:13 +0000 Subject: MdeModulePkg:Fix a bug HttpLib can't parse last chunked data well When HttpLib parsing the last chunked data down, the Http NextMsg pointer in the HttpBodyParserCallback function should point to the character after '/n' flag. (Sync patch r19310 from main trunk.) Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Zhang Lubo Reviewed-by: Fu Siyuan Reviewed-by: Ye Ting Reviewed-by: Wu Jiaxin git-svn-id: https://svn.code.sf.net/p/edk2/code/branches/UDK2015@19324 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c | 39 +++++++++++++++++----------- 1 file changed, 24 insertions(+), 15 deletions(-) (limited to 'MdeModulePkg/Library/DxeHttpLib') diff --git a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c index 500b3c72b3..6b830fdd9b 100644 --- a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c +++ b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c @@ -1161,21 +1161,7 @@ HttpParseMessageBody ( switch (Parser->State) { case BodyParserStateMax: return EFI_ABORTED; - - case BodyParserComplete: - if (Parser->Callback != NULL) { - Status = Parser->Callback ( - BodyParseEventOnComplete, - Char, - 0, - Parser->Context - ); - if (EFI_ERROR (Status)) { - return Status; - } - } - return EFI_SUCCESS; - + case BodyParserBodyIdentity: // // Identity transfer-coding, just notify user to save the body data. @@ -1195,6 +1181,17 @@ HttpParseMessageBody ( Parser->ParsedBodyLength += MIN (BodyLength, Parser->ContentLength - Parser->ParsedBodyLength); if (Parser->ParsedBodyLength == Parser->ContentLength) { Parser->State = BodyParserComplete; + if (Parser->Callback != NULL) { + Status = Parser->Callback ( + BodyParseEventOnComplete, + Char, + 0, + Parser->Context + ); + if (EFI_ERROR (Status)) { + return Status; + } + } } break; @@ -1272,6 +1269,18 @@ HttpParseMessageBody ( case BodyParserLastCRLFEnd: if (*Char == '\n') { Parser->State = BodyParserComplete; + Char++; + if (Parser->Callback != NULL) { + Status = Parser->Callback ( + BodyParseEventOnComplete, + Char, + 0, + Parser->Context + ); + if (EFI_ERROR (Status)) { + return Status; + } + } break; } else { Parser->State = BodyParserStateMax; -- cgit v1.2.3