×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Feb 2009
    Posts
    1

    This is the right method to use POST?

    Hi, all. I want to use POST to send some data to my server. I encapsulate the sending method in a class, and this is the code of the method:
    void SendVerifyInfo(const TDesC& aUsername,const TDesC& aPassword)
    {
    TBuf8<20> iTemp;
    TBuf8<20> iTemp2;
    TUriParser8 uri;
    _LIT8(KPostParamName1, "username");
    _LIT8(KPostParamName2, "password");
    // http server URI
    _LIT8(httpSvrURI, "http://192.168.1.101/login.html");
    User::LeaveIfError ( uri.Parse(httpSvrURI) );

    RHTTPTransaction trans = iSession.OpenTransactionL(uri, iTransObs, iSession.StringPool().StringF(HTTP::EPOST,RHTTPSession::GetTable()));


    pFormEncoder = CHTTPFormEncoder::NewL();
    iTemp.Copy(aUsername);
    iTemp2.Copy(KPostParamName1);
    pFormEncoder->AddFieldL(iTemp2,iTemp);

    iTemp.Copy(aPassword);
    iTemp2.Copy(KPostParamName2);
    pFormEncoder->AddFieldL(iTemp2,iTemp);
    trans.Request().SetBody(*pFormEncoder);
    trans.SubmitL();

    CActiveScheduler::Start();
    }

    when i debug it, the console window(in Carbide C++) print some messages like this:

    223.630 Demo Filter: New transaction submitted, URI: http://192.168.1.101/login.html
    223.630 HTTPPLUGIN:MHFRunL: EClosed (3)

    The demo send this POST request periodicly. But my webserver, which in the same machine, can not receive any POST request while the GET request can be received.

    Anybody can help me to point out any problems with my code? thank you very much. I have been stopped by this problem by a long time.

  2. #2
    Registered User
    Join Date
    Aug 2006
    Posts
    182

    Re: This is the right method to use POST?

    Quote Originally Posted by gardner_xu View Post
    Hi, all. I want to use POST to send some data to my server. I encapsulate the sending method in a class, and this is the code of the method:
    void SendVerifyInfo(const TDesC& aUsername,const TDesC& aPassword)
    {
    TBuf8<20> iTemp;
    TBuf8<20> iTemp2;
    TUriParser8 uri;
    _LIT8(KPostParamName1, "username");
    _LIT8(KPostParamName2, "password");
    // http server URI
    _LIT8(httpSvrURI, "http://192.168.1.101/login.html");
    User::LeaveIfError ( uri.Parse(httpSvrURI) );

    RHTTPTransaction trans = iSession.OpenTransactionL(uri, iTransObs, iSession.StringPool().StringF(HTTP::EPOST,RHTTPSession::GetTable()));


    pFormEncoder = CHTTPFormEncoder::NewL();
    iTemp.Copy(aUsername);
    iTemp2.Copy(KPostParamName1);
    pFormEncoder->AddFieldL(iTemp2,iTemp);

    iTemp.Copy(aPassword);
    iTemp2.Copy(KPostParamName2);
    pFormEncoder->AddFieldL(iTemp2,iTemp);
    trans.Request().SetBody(*pFormEncoder);
    trans.SubmitL();

    CActiveScheduler::Start();
    }

    when i debug it, the console window(in Carbide C++) print some messages like this:

    223.630 Demo Filter: New transaction submitted, URI: http://192.168.1.101/login.html
    223.630 HTTPPLUGIN:MHFRunL: EClosed (3)

    The demo send this POST request periodicly. But my webserver, which in the same machine, can not receive any POST request while the GET request can be received.

    Anybody can help me to point out any problems with my code? thank you very much. I have been stopped by this problem by a long time.
    Did you refer the HTTP Client Example provided byt the forum nokia. It demonstrates how to POST data to server:

    Refer following link to access the same:
    http://www.forum.nokia.com/info/sw.n...I_Example.html

    Regards,
    PS: Before posting do try wiki search to save your time and effort:
    http://wiki.forum.nokia.com/index.php/Wiki_Home

Similar Threads

  1. A problem about Http POST
    By wanghuasong1001 in forum Symbian Networking & Messaging (Closed)
    Replies: 6
    Last Post: 2009-08-03, 10:09
  2. Problem with HTTP POST
    By thathoo in forum Mobile Java General
    Replies: 2
    Last Post: 2006-12-18, 18:23
  3. Methods, that take lots of space
    By doctordwarf in forum Mobile Java General
    Replies: 4
    Last Post: 2003-07-30, 11:05
  4. Networking : POST method on Nokia 3510i
    By pytheas in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2003-07-14, 21:44

Posting Permissions

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