Revision: 18213
http://sourceforge.net/p/edk2/code/18213
Author: luobozhang
Date: 2015-08-12 12:44:31 +0000 (Wed, 12 Aug 2015)
Log Message:
-----------
MdeModulePkg: Add codes to support trailer parse in HttpLib.
In HttpLib, the Event BodyParseComplete should return to the
callback function when the whole message body has been parsed
including the trailer if it has.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo <[email protected]>
Reviewed-by: Ye Ting <[email protected]>
Reviewed-by: Wu Jiaxin <[email protected]>
Reviewed-by: Fu Siyuan <[email protected]>
Modified Paths:
--------------
trunk/edk2/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
Modified: trunk/edk2/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
===================================================================
--- trunk/edk2/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c 2015-08-12
05:25:48 UTC (rev 18212)
+++ trunk/edk2/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c 2015-08-12
12:44:31 UTC (rev 18213)
@@ -818,6 +818,9 @@
BodyParserChunkDataStart,
BodyParserChunkDataEnd,
BodyParserChunkDataEndCR,
+ BodyParserTrailer,
+ BodyParserLastCRLF,
+ BodyParserLastCRLFEnd,
BodyParserComplete,
BodyParserStateMax
} HTTP_BODY_PARSE_STATE;
@@ -1212,21 +1215,52 @@
Parser->State = BodyParserStateMax;
break;
}
- Parser->State = BodyParserChunkDataStart;
- Parser->CurrentChunkParsedSize = 0;
Char++;
- break;
-
- case BodyParserChunkDataStart:
if (Parser->CurrentChunkSize == 0) {
//
- // This is the last chunk, the trailer header is unsupported.
+ // The last chunk has been parsed and now assumed the state
+ // of HttpBodyParse is ParserLastCRLF. So it need to decide
+ // whether the rest message is trailer or last CRLF in the next round.
//
Parser->ContentLengthIsValid = TRUE;
+ Parser->State = BodyParserLastCRLF;
+ break;
+ }
+ Parser->State = BodyParserChunkDataStart;
+ Parser->CurrentChunkParsedSize = 0;
+ break;
+
+ case BodyParserLastCRLF:
+ //
+ // Judge the byte is belong to the Last CRLF or trailer, and then
+ // configure the state of HttpBodyParse to corresponding state.
+ //
+ if (*Char == '\r') {
+ Char++;
+ Parser->State = BodyParserLastCRLFEnd;
+ break;
+ } else {
+ Parser->State = BodyParserTrailer;
+ break;
+ }
+
+ case BodyParserLastCRLFEnd:
+ if (*Char == '\n') {
Parser->State = BodyParserComplete;
break;
+ } else {
+ Parser->State = BodyParserStateMax;
+ break;
}
+ case BodyParserTrailer:
+ if (*Char == '\r') {
+ Parser->State = BodyParserChunkSizeEndCR;
+ }
+ Char++;
+ break;
+
+ case BodyParserChunkDataStart:
//
// First byte of chunk-data, the chunk data also might be truncated.
//
------------------------------------------------------------------------------
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits