void CSyncHttpConnection::StateChange(THttpEngineState aState) { iEngineStatus = aState; //CommonUtils::WriteLogL(_L("CSyncHttpConnection::StateChange iEngineStatus = "), iEngineStatus); switch (aState) { case EHttpError: case EHttpGetHeaderTimeOut: case EHttpGetBodyTimeOut: case EHttpFinished: if (iWait->IsStarted()) { iWait->AsyncStop(); } break; case EGetHeader: break; case ERedirect: { HBufC8* head = iConnection->GetResponeHeader(); TPtrC8 redirectUrl; if (head) { _LIT8(GOHREF, "Location:"); TInt redirectUrlIndex = head->FindC(GOHREF); if (redirectUrlIndex >= 0) { redirectUrl.Set(head->Right(head->Length() - redirectUrlIndex - GOHREF().Length())); _LIT8(SPACE, " "); redirectUrlIndex = redirectUrl.FindC(SPACE); while (redirectUrlIndex == 0) { redirectUrl.Set(redirectUrl.Right(redirectUrl.Length() - redirectUrlIndex - SPACE().Length())); redirectUrlIndex = redirectUrl.FindC(SPACE); } redirectUrlIndex = redirectUrl.FindC(_L8("\r\n")); if (redirectUrlIndex >= 0) { redirectUrl.Set(redirectUrl.Left(redirectUrlIndex)); } } } if (redirectUrl.Length() > 0) { TBuf<200> aUri; aUri.Copy(redirectUrl); //CommonUtils::WriteLogL(_L("CSyncHttpConnection::StateChange redirectUrl = "), aUri); iConnection->ResetVarible(); iConnection->Stop(); iConnection->GetRequestL(aUri, 0); iConnection->sendRequest(); } else { //CommonUtils::WriteLogL(_L("CSyncHttpConnection::StateChange ERedirect error"), _L("")); iEngineStatus = EHttpError; if (iWait->IsStarted()) { iWait->AsyncStop(); } } } break; default: if (iWait->IsStarted()) { iWait->AsyncStop(); } break; } }