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).
TInt statusCode = iStatus.Int();
if (!iConnectionSetupDone && statusCode == KErrNone)
// Connection done ok
iConnectionSetupDone = ETrue;
// Start selected HTTP action
// Connection setup is done
// Open HTTP Session
// Open socket server and start the connection
void CHTTPEngine::IssueHTTPPostL(const TDesC8& aUri,
const TDesC8& aContentType,
const TDesC8& aBody)
iEngineState = EPost;
iUri = NULL;
iContentType = NULL;
iBody = NULL;
iUri = aUri.AllocL();
iContentType = aContentType.AllocL();
iBody = aBody.AllocL();
// Create HTTP connection
if (err == KErrAlreadyExists)
if (err != KErrNone)
if(err == KErrCouldNotConnect)
// Parse string to URI
// Copy data to be posted into member variable; iPostData is used later in
// methods inherited from MHTTPDataSupplier.
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;
// Submit the transaction. After this the framework will give transaction
// events via MHFRunL and MHFRunError.
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.