本文整理汇总了C++中StringParser::ConsumeLength方法的典型用法代码示例。如果您正苦于以下问题:C++ StringParser::ConsumeLength方法的具体用法?C++ StringParser::ConsumeLength怎么用?C++ StringParser::ConsumeLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringParser
的用法示例。
在下文中一共展示了StringParser::ConsumeLength方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParseURI
//returns: SyntaxError if there was an error in the uri. Or InternalServerError
QTSS_Error RTSPRequest::ParseURI(StringParser &parser)
{
//read in the complete URL, set it to be the qtssAbsoluteURLParam
StrPtrLen theAbsURL;
// RTSPRequestInterface::sPathURLStopConditions stop on ? as well as sURLStopConditions
parser.ConsumeUntil(&theAbsURL, sURLStopConditions );
// set qtssRTSPReqAbsoluteURL to the URL throught the path component; will be : <protocol>://<host-addr>/<path>
this->SetVal(qtssRTSPReqAbsoluteURL, &theAbsURL);
StringParser urlParser(&theAbsURL);
//we always should have a slash before the uri.
//If not, that indicates this is a full URI. Also, this could be a '*' OPTIONS request
if ((*theAbsURL.Ptr != '/') && (*theAbsURL.Ptr != '*'))
{
//if it is a full URL, store the host name off in a separate parameter
StrPtrLen theRTSPString;
urlParser.ConsumeLength(&theRTSPString, 7); //consume "rtsp://"
//assign the host field here to the proper QTSS param
StrPtrLen theHost;
urlParser.ConsumeUntil(&theHost, '/');
fHeaderDictionary.SetVal(qtssHostHeader, &theHost);
}
// don't allow non-aggregate operations indicated by a url/media track=id
// might need this for rate adapt if (qtssSetupMethod != fMethod && qtssOptionsMethod != fMethod && qtssSetParameterMethod != fMethod) // any method not a setup, options, or setparameter is not allowed to have a "/trackID=" in the url.
if (qtssSetupMethod != fMethod) // any method not a setup is not allowed to have a "/trackID=" in the url.
{
StrPtrLenDel tempCStr(theAbsURL.GetAsCString());
StrPtrLen nonaggregate(tempCStr.FindString("/trackID="));
if (nonaggregate.Len > 0) // check for non-aggregate method and return error
return QTSSModuleUtils::SendErrorResponse(this, qtssClientAggregateOptionAllowed, qtssMsgBadRTSPMethod, &theAbsURL);
}
// don't allow non-aggregate operations like a setup on a playing session
if (qtssSetupMethod == fMethod) // if it is a setup but we are playing don't allow it
{
RTSPSession* theSession = (RTSPSession*)this->GetSession();
if (theSession != NULL && theSession->IsPlaying())
return QTSSModuleUtils::SendErrorResponse(this, qtssClientAggregateOptionAllowed, qtssMsgBadRTSPMethod, &theAbsURL);
}
//
// In case there is no URI at all... we have to fake it.
static char* sSlashURI = "/";
//whatever is in this position in the URL must be the URI. Store that
//in the qtssURLParam. Confused?
UInt32 uriLen = urlParser.GetDataReceivedLen() - urlParser.GetDataParsedLen();
if (uriLen > 0)
this->SetVal(qtssRTSPReqURI, urlParser.GetCurrentPosition(), urlParser.GetDataReceivedLen() - urlParser.GetDataParsedLen());
else
//
// This might happen if there is nothing after the host at all, not even
// a '/'. This is legal (RFC 2326, Sec 3.2). If so, just pretend that there
// is a '/'
this->SetVal(qtssRTSPReqURI, sSlashURI, 1);
// parse the query string from the url if present.
// init qtssRTSPReqQueryString dictionary to an empty string
StrPtrLen queryString;
this->SetVal(qtssRTSPReqQueryString, queryString.Ptr, queryString.Len);
if ( parser.GetDataRemaining() > 0 )
{
if ( parser.PeekFast() == '?' )
{
// we've got some CGI param
parser.ConsumeLength(&queryString, 1); // toss '?'
// consume the rest of the line..
parser.ConsumeUntilWhitespace(&queryString);
this->SetVal(qtssRTSPReqQueryString, queryString.Ptr, queryString.Len);
}
}
//
// If the is a '*', return right now because '*' is not a path
// so the below functions don't make any sense.
if ((*theAbsURL.Ptr == '*') && (theAbsURL.Len == 1))
{
this->SetValue(qtssRTSPReqFilePath, 0, theAbsURL.Ptr, theAbsURL.Len, QTSSDictionary::kDontObeyReadOnly);
return QTSS_NoErr;
}
//path strings are statically allocated. Therefore, if they are longer than
//this length we won't be able to handle the request.
StrPtrLen* theURLParam = this->GetValue(qtssRTSPReqURI);
if (theURLParam->Len > RTSPRequestInterface::kMaxFilePathSizeInBytes)
return QTSSModuleUtils::SendErrorResponse(this, qtssClientBadRequest, qtssMsgURLTooLong, theURLParam);
//decode the URL, put the result in the separate buffer for the file path,
//set the file path StrPtrLen to the proper value
SInt32 theBytesWritten = StringTranslator::DecodeURL(theURLParam->Ptr, theURLParam->Len,
//.........这里部分代码省略.........