void ParseHostString (const XBOX::VString& inHostString, XBOX::VString& outIPv4String, PortNumber& outPort) { XBOX::VIndex pos = inHostString.FindUniChar (CHAR_COLON); if (pos > 0) { XBOX::VString portString; inHostString.GetSubString (1, pos - 1, outIPv4String); inHostString.GetSubString (pos + 1, inHostString.GetLength() - pos, portString); outPort = portString.GetLong(); } else { outIPv4String.FromString (inHostString); outPort = DEFAULT_LISTENING_PORT; } }
void VHTTPCookie::FromString (const XBOX::VString& inString) { XBOX::VectorOfVString stringValues; XBOX::VString string; XBOX::VString nameString; XBOX::VString valueString; Clear(); inString.GetSubStrings (CHAR_SEMICOLON, stringValues, false, true); for (VectorOfVString::iterator it = stringValues.begin(); it != stringValues.end(); ++it) { sLONG pos = 0; string.FromString (*it); if ((pos = HTTPTools::FindASCIICString (string, "secure")) == 1) { SetSecure (true); } else if ((pos = HTTPTools::FindASCIICString (string, "httpOnly")) == 1) { SetHttpOnly (true); } else if ((pos = HTTPTools::FindASCIICString (string, "version")) == 1) { SetVersion (1); } else if ((pos = HTTPTools::FindASCIICString (string, "max-age")) == 1) { HTTPTools::ExtractFieldNameValue (string, nameString, valueString); fMaxAge = valueString.GetLong(); } else if ((pos = HTTPTools::FindASCIICString (string, "expires")) == 1) { XBOX::VTime curTime; XBOX::VTime expiresTime; XBOX::VTime::Now (curTime); HTTPTools::ExtractFieldNameValue (string, nameString, valueString); expiresTime.FromRfc822String (valueString); if (expiresTime.GetMilliseconds() > curTime.GetMilliseconds()) fMaxAge = (expiresTime.GetMilliseconds() - curTime.GetMilliseconds()) / 1000; } else if ((pos = HTTPTools::FindASCIICString (string, "path")) == 1) { HTTPTools::ExtractFieldNameValue (string, nameString, fPath); } else if ((pos = HTTPTools::FindASCIICString (string, "domain")) == 1) { HTTPTools::ExtractFieldNameValue (string, nameString, fDomain); } else if ((pos = HTTPTools::FindASCIICString (string, "comment")) == 1) { HTTPTools::ExtractFieldNameValue (string, nameString, fComment); } else if ((pos = HTTPTools::FindASCIICString (string, "="))) { HTTPTools::ExtractFieldNameValue (string, fName, fValue); } } }