mirror of https://github.com/acidanthera/audk.git
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 <lubo.zhang@intel.com> Reviewed-by: Ye Ting <ting.ye@intel.com> Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com> Reviewed-by: Fu Siyuan <siyuan.fu@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18213 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
64ffb95441
commit
0cd1ecea67
|
@ -818,6 +818,9 @@ typedef enum {
|
|||
BodyParserChunkDataStart,
|
||||
BodyParserChunkDataEnd,
|
||||
BodyParserChunkDataEndCR,
|
||||
BodyParserTrailer,
|
||||
BodyParserLastCRLF,
|
||||
BodyParserLastCRLFEnd,
|
||||
BodyParserComplete,
|
||||
BodyParserStateMax
|
||||
} HTTP_BODY_PARSE_STATE;
|
||||
|
@ -1212,21 +1215,52 @@ HttpParseMessageBody (
|
|||
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 = BodyParserComplete;
|
||||
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.
|
||||
//
|
||||
|
|
Loading…
Reference in New Issue