本文整理汇总了C++中StringParser::ConsumeEOL方法的典型用法代码示例。如果您正苦于以下问题:C++ StringParser::ConsumeEOL方法的具体用法?C++ StringParser::ConsumeEOL怎么用?C++ StringParser::ConsumeEOL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringParser
的用法示例。
在下文中一共展示了StringParser::ConsumeEOL方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParseHeaders
//throws eHTTPNoMoreData and eHTTPOutOfBuffer
QTSS_Error RTSPRequest::ParseHeaders(StringParser& parser)
{
StrPtrLen theKeyWord;
Bool16 isStreamOK;
//Repeat until we get a \r\n\r\n, which signals the end of the headers
while ((parser.PeekFast() != '\r') && (parser.PeekFast() != '\n'))
{
//First get the header identifier
isStreamOK = parser.GetThru(&theKeyWord, ':');
if (!isStreamOK)
return QTSSModuleUtils::SendErrorResponse(this, qtssClientBadRequest, qtssMsgNoColonAfterHeader, this->GetValue(qtssRTSPReqFullRequest));
theKeyWord.TrimWhitespace();
//Look up the proper header enumeration based on the header string.
//Use the enumeration to look up the dictionary ID of this header,
//and set that dictionary attribute to be whatever is in the body of the header
UInt32 theHeader = RTSPProtocol::GetRequestHeader(theKeyWord);
StrPtrLen theHeaderVal;
parser.ConsumeUntil(&theHeaderVal, StringParser::sEOLMask);
StrPtrLen theEOL;
if ((parser.PeekFast() == '\r') || (parser.PeekFast() == '\n'))
{
isStreamOK = true;
parser.ConsumeEOL(&theEOL);
}
else
isStreamOK = false;
while((parser.PeekFast() == ' ') || (parser.PeekFast() == '\t'))
{
theHeaderVal.Len += theEOL.Len;
StrPtrLen temp;
parser.ConsumeUntil(&temp, StringParser::sEOLMask);
theHeaderVal.Len += temp.Len;
if ((parser.PeekFast() == '\r') || (parser.PeekFast() == '\n'))
{
isStreamOK = true;
parser.ConsumeEOL(&theEOL);
}
else
isStreamOK = false;
}
// If this is an unknown header, ignore it. Otherwise, set the proper
// dictionary attribute
if (theHeader != qtssIllegalHeader)
{
Assert(theHeader < qtssNumHeaders);
theHeaderVal.TrimWhitespace();
fHeaderDictionary.SetVal(theHeader, &theHeaderVal);
}
if (!isStreamOK)
return QTSSModuleUtils::SendErrorResponse(this, qtssClientBadRequest, qtssMsgNoEOLAfterHeader);
//some headers require some special processing. If this code begins
//to get out of control, we made need to come up with a function pointer table
switch (theHeader)
{
case qtssSessionHeader: ParseSessionHeader(); break;
case qtssTransportHeader: ParseTransportHeader(); break;
case qtssRangeHeader: ParseRangeHeader(); break;
case qtssIfModifiedSinceHeader: ParseIfModSinceHeader();break;
case qtssXRetransmitHeader: ParseRetransmitHeader();break;
case qtssContentLengthHeader: ParseContentLengthHeader();break;
case qtssSpeedHeader: ParseSpeedHeader(); break;
case qtssXTransportOptionsHeader: ParseTransportOptionsHeader();break;
case qtssXPreBufferHeader: ParsePrebufferHeader();break;
case qtssXDynamicRateHeader: ParseDynamicRateHeader(); break;
case qtssXRandomDataSizeHeader: ParseRandomDataSizeHeader(); break;
case qtss3GPPAdaptationHeader: fRequest3GPP.ParseAdpationHeader(&fHeaderDictionary); break;
case qtss3GPPLinkCharHeader: fRequest3GPP.ParseLinkCharHeader(&fHeaderDictionary); break;
case qtssBandwidthHeader: ParseBandwidthHeader(); break;
default: break;
}
}
// Tell the session what the request body length is for this request
// so that it can prevent people from reading past the end of the request.
StrPtrLen* theContentLengthBody = fHeaderDictionary.GetValue(qtssContentLengthHeader);
if (theContentLengthBody->Len > 0)
{
StringParser theHeaderParser(fHeaderDictionary.GetValue(qtssContentLengthHeader));
theHeaderParser.ConsumeWhitespace();
this->GetSession()->SetRequestBodyLength(theHeaderParser.ConsumeInteger(NULL));
}
isStreamOK = parser.ExpectEOL();
Assert(isStreamOK);
return QTSS_NoErr;
}