×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Oct 2009
    Posts
    11

    about THTTPEvent.iStatus -46 problem

    Platform: S60v3
    Language: Symbian C++
    Function: commnunication by http
    Problem: I want to get a URL page from web by http. It is normally when I test my programm on Epoc.
    I ecounter a problem about THTTPEvent.iStatus = -46 when I test my programm in S60V3machine.
    Anybody could help me?Thanks.

    The follow is my code:




    void CHttpClient::ConstructL(CConsoleBase* console)
    {
    this->console = console;
    // Open the RHTTPSession
    iSess.OpenL();

    // Install this class as the callback for authentication requests
    InstallAuthenticationL(iSess);

    iTransObs = CHttpEventHandler::NewL(console);
    console->Write(_L("CHttpClient::ConstructL is over.\n"));
    console->Printf(KTextPressAnyKey);
    console->Getch();
    }

    void CHttpClient::SetHeaderL(RHTTPHeaders aHeaders, TInt aHdrField,
    const TDesC8& aHdrValue)
    {

    RStringF valStr = iSess.StringPool().OpenFStringL(aHdrValue);
    THTTPHdrVal val(valStr);
    aHeaders.SetFieldL(iSess.StringPool().StringF(aHdrField,
    RHTTPSession::GetTable()), val);
    valStr.Close();
    }

    void CHttpClient::InvokeHttpGetL(const TDesC8& aUri)
    {

    // Initialise the socket server session.
    RSocketServ socketServ;
    User::LeaveIfError(socketServ.Connect());

    // Initialise the RConnection.
    RConnection connection;
    User::LeaveIfError(connection.Open(socketServ));

    // open the IAP communications database
    CCommsDatabase* commDB = CCommsDatabase::NewL(EDatabaseTypeIAP);
    CleanupStack::PushL(commDB);

    // initialize a view
    CCommsDbConnectionPrefTableView* commDBView =
    commDB->OpenConnectionPrefTableInRankOrderLC(
    ECommDbConnectionDirectionOutgoing);

    // go to the first record
    User::LeaveIfError(commDBView->GotoFirstRecord());

    // Declare a prefTableView Object.
    CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref;

    // read the connection preferences
    commDBView->ReadConnectionPreferenceL(pref);
    TUint32 iapID = pref.iBearer.iIapId;

    // pop and destroy the IAP View
    CleanupStack::PopAndDestroy(commDBView);

    // pop and destroy the database object
    CleanupStack::PopAndDestroy(commDB);

    // Now we have the iap Id. Use it to connect for the connection.
    // Create a connection preference variable.
    TCommDbConnPref connectPref;

    // setup preferences
    connectPref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
    connectPref.SetDirection(ECommDbConnectionDirectionOutgoing);
    connectPref.SetBearerSet(ECommDbBearerGPRS);
    connectPref.SetIapId(iapID);

    // start a synchronous connection
    TInt errConnect = connection.Start(connectPref);

    //Then, associate the current socket server session and rconnection object
    //used above with the HttpSession which u will be using.

    RStringPool strP2 = iSess.StringPool();
    RHTTPConnectionInfo connInfo = iSess.ConnectionInfo();
    connInfo.SetPropertyL(strP2.StringF(HTTP::EHttpSocketServ,
    RHTTPSession::GetTable()), THTTPHdrVal(socketServ.Handle()));
    TInt connPtr = REINTERPRET_CAST(TInt, &(connection));
    connInfo.SetPropertyL(strP2.StringF(HTTP::EHttpSocketConnection,
    RHTTPSession::GetTable()), THTTPHdrVal(connPtr));

    RStringPool strP = iSess.StringPool();
    RStringF method = strP.StringF(HTTP::EGET, RHTTPSession::GetTable());
    iDataChunkCount = 0;
    TUriParser8 uri;
    uri.Parse(aUri);
    iTrans = iSess.OpenTransactionL(uri, *iTransObs, method);
    RHTTPHeaders hdr = iTrans.Request().GetHeaderCollection();
    // Add headers appropriate to all methods
    SetHeaderL(hdr, HTTP::EUserAgent, KUserAgent);
    SetHeaderL(hdr, HTTP::EAccept, KAccept);

    // submit the transaction
    iTrans.SubmitL();

    }

    void CHttpEventHandler::ConstructL(CConsoleBase* console)
    {
    this->console = console;
    User::LeaveIfError(iFileServ.Connect());
    _LIT(KFileName,"data.html");
    iRespBodyFileName.Append(KFileName);
    iParsedFileName.Set(KFileSystemRoot, &iRespBodyFileName, NULL);

    TInt err = iRespBodyFile.Replace(iFileServ, iParsedFileName.FullName(),
    EFileWrite | EFileShareExclusive);

    }



    TInt CHttpEventHandler::MHFRunError(TInt aError, RHTTPTransaction aTransaction,
    const THTTPEvent& aEvent)
    {
    return 0;
    }

    void CHttpEventHandler::MHFRunL(RHTTPTransaction aTransaction,
    const THTTPEvent& aEvent)
    {
    console->Printf(_L("aEvent.iStatus=%d\n"),aEvent.iStatus);
    switch (aEvent.iStatus)
    {
    case THTTPEvent::EGotResponseHeaders:
    break;

    case THTTPEvent::EGotResponseBodyData:
    {
    // Get the body data supplier
    iRespBody = aTransaction.Response().Body();
    // Append to the output file if we're saving responses
    if (true)
    {
    TPtrC8 bodyData;
    TBool lastChunk = iRespBody->GetNextDataPart(bodyData);
    iRespBodyFile.Write(bodyData);
    if (lastChunk)
    iRespBodyFile.Close();
    }

    // Done with that bit of body data
    iRespBody->ReleaseData();
    }break;
    case THTTPEvent::EResponseComplete:
    break;
    case THTTPEvent::ESucceeded:
    {
    aTransaction.Close();
    CActiveScheduler::Stop();
    }break;
    case THTTPEvent::EFailed:
    break;
    case THTTPEvent::ERedirectedPermanently:
    break;
    case THTTPEvent::ERedirectedTemporarily:
    break;
    default:
    {

    if (aEvent.iStatus < 0)
    {
    aTransaction.Close();
    CActiveScheduler::Stop();
    }
    }break;
    }
    }
    Last edited by napoleon.guo; 2009-11-19 at 09:35. Reason: format is so urgly

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,170

    Re: about THTTPEvent.iStatus -46 problem

    Try it out in a emulator, and see the epocwind.out for any platsec warnings for missing capabilities.

  3. #3
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,752

    Re: about THTTPEvent.iStatus -46 problem

    -46: http://wiki.forum.nokia.com/index.php/Error_codes
    epocwind.out: http://wiki.forum.nokia.com/index.php/Epocwind.out

    ugly format: surround your code with [CODE ] and [/CODE ] tags (without the spaces). The "advanced" editor also supports that (select the text and click on "#")
    Then
    void Hello()
    {
    printf("Hello");
    }
    will become
    Code:
    void Hello()
    {
        printf("Hello");
    }

  4. #4
    Registered User
    Join Date
    Oct 2009
    Posts
    11

    Re: about THTTPEvent.iStatus -46 problem

    thanks to wizard_hu_ ,thanks to symbianyucca . I am very grateful to you.

Similar Threads

  1. Problem with CAknDoubleStyleListBox with a CAknSearchField
    By jjig in forum Symbian User Interface
    Replies: 2
    Last Post: 2009-09-17, 00:58
  2. help:RSocket.Connect Problem! -46 iStatus HTTP GET
    By ahmadaa_h in forum Symbian Networking & Messaging (Closed)
    Replies: 7
    Last Post: 2007-10-05, 03:41
  3. Problem with eglSwapBuffers and heap corruption
    By greatape in forum Symbian Media (Closed)
    Replies: 2
    Last Post: 2007-05-24, 03:35
  4. netcards - Problem with opening adapter
    By kernj in forum Symbian Tools & SDKs
    Replies: 5
    Last Post: 2007-01-10, 08:56
  5. Problem: S60 SDK for CW in PC with .NET
    By anttij in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 1
    Last Post: 2005-02-28, 11:36

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×