The following code ends up prompting the user for APN selection twice consecutively. I can't find why:
(I only included the part of the code that I think is relevant in the HTTPEngine class).Code:void CHTTPEngine::RunL() { TInt statusCode = iStatus.Int(); if (!iConnectionSetupDone && statusCode == KErrNone) { // Connection done ok iConnectionSetupDone = ETrue; // Start selected HTTP action switch (iEngineState) { case EPost: { DoHTTPPostL(); break; } ................ }; } } void CHTTPEngine::SetupConnectionL() { if (iConnectionSetupDone) { // Connection setup is done User::Leave(KErrAlreadyExists); } if (IsActive()) { User::Leave(KErrInUse); } // Open HTTP Session iSession.OpenL(); // Open socket server and start the connection User::LeaveIfError(iSocketServ.Connect()); User::LeaveIfError(iConnection.Open(iSocketServ)); iConnection.Start(iStatus); SetActive(); } void CHTTPEngine::IssueHTTPPostL(const TDesC8& aUri, const TDesC8& aContentType, const TDesC8& aBody) { if (IsActive()) { return; } iEngineState = EPost; delete iUri; iUri = NULL; delete iContentType; iContentType = NULL; delete iBody; iBody = NULL; iUri = aUri.AllocL(); iContentType = aContentType.AllocL(); iBody = aBody.AllocL(); // Create HTTP connection TRAPD(err, SetupConnectionL()); if (err == KErrAlreadyExists) { DoHTTPPostL(); } else { if (err != KErrNone) { iObserver->HTTPEvent(MHTTPObserver::ETxCancelled); return; } else { if(err == KErrCouldNotConnect) { iObserver->HTTPEvent(MHTTPObserver::EHTTPEng_Offline); return; } } } } void CHTTPEngine::DoHTTPPostL() { // Parse string to URI TUriParser8 uri; uri.Parse(*iUri); // Copy data to be posted into member variable; iPostData is used later in // methods inherited from MHTTPDataSupplier. delete iPostData; iPostData = 0; iPostData = iBody->AllocL(); // Get request method string for HTTP POST RStringF method = iSession.StringPool().StringF(HTTP::EPOST, RHTTPSession::GetTable()); // Open transaction with previous method and parsed uri. This class will // receive transaction events in MHFRunL and MHFRunError. iTransaction = iSession.OpenTransactionL(uri, *this, method); iTransactionOpen = ETrue; // Set headers for request; user agent, accepted content type and body's // content type. RHTTPHeaders hdr = iTransaction.Request().GetHeaderCollection(); SetHeaderL(hdr, HTTP::EUserAgent, KUserAgent); SetHeaderL(hdr, HTTP::EAccept, KAccept); SetHeaderL(hdr, HTTP::EContentType, *iContentType); // Set this class as an data supplier. Inherited MHTTPDataSupplier methods // are called when framework needs to send body data. MHTTPDataSupplier* dataSupplier = this; iTransaction.Request().SetBody(*dataSupplier); // Submit the transaction. After this the framework will give transaction // events via MHFRunL and MHFRunError. iTransaction.SubmitL(); iObserver->HTTPEvent(MHTTPObserver::EConnecting); }
The application calls IssueHTTPPostL() to send data to the server.
If iConnection is not established then, the red line is executed. At that point, the user is prompted to select IAP for the first time.
The, Run() and DoHTTPPostL() are executed. just after DoHTTPPostL() exits, the user is prompted a second time to select IAP.
As far as I can see from logs and from hits to MHFRunL() (MHTTPSessionEventCallback observer), the user seems to be prompted twice before anything is sent to server. And I am sure that SetupConnectionL() is only entered once.
Please, help!


oHTTPPostL() to add a the blue lines bellow:


