Программирование в IIS




Анализ пары "Заголовок-Значение" - часть 2


Returns data about the search parameters if found or not. /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ bool GetHeaderValuePair(const string &sHeader, const int &nStart, string *psName, string *psValue, int *pnEnd) { const string sColon(":");

//determine if header is a post header string::size_type idxColonPosition = nStart;

//start looking at beginning idxColonPosition = sHeader.find(sColon, idxColonPosition);

if (idxColonPosition == string::npos)//no more headers found return false;//this is failure

//get the name psName->assign(sHeader.substr (nStart, idxColonPosition - nStart));

//find next newline string::size_type idxNewLine; idxNewLine = sHeader.find('\n', idxColonPosition);

//get the end even if it means not found *pnEnd = idxNewLine;

if (idxNewLine == string::npos) //a newline was not found return true;//not a failure - might be the last header

//get the value //adjust colon position so we do not assign colon in value idxColonPosition = idxColonPosition +1; psValue->assign(sHeader.substr(idxColonPosition, idxNewLine - idxColonPosition));

return true;

Листинг 5.6. Source Code for Function GetHeaderValuePair




Содержание  Назад  Вперед