×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Regular Contributor
    Join Date
    Feb 2004
    Posts
    130

    HTTP POST Problem

    hi there,

    i have a problem on http post.
    here is my codes:

    void CSocketsEngine::SendL()
    {
    RFs fs;
    RFile exfile;
    TInt err,len;
    HBufC8* outLine;

    User::LeaveIfError(fs.Connect());
    User::LeaveIfError(exfile.Open(fs,KEncoded,EFileRead|EFileStreamText)); //read encoded text

    // get length file size + account & password length + constant length
    exfile.Size(len);
    len += (*iContainer.iArrayGPRS)[iNumber].iUsername.Length();
    len += (*iContainer.iArrayGPRS)[iNumber].iPassword.Length();
    len += (*iContainer.iArrayGPRS)[iNumber].iName.Length();
    len += (*iContainer.iArrayGPRS)[iNumber].iAlbum.Length();
    len += (*iContainer.iArrayGPRS)[iNumber].iUniqueID.Length();

    if((*iContainer.iArrayGPRS)[iNumber].iLocation.Length()>0)
    {
    len += (*iContainer.iArrayGPRS)[iNumber].iLocation.Length();
    len += (*iContainer.iArrayGPRS)[iNumber].iSize2R.Length();
    len += (*iContainer.iArrayGPRS)[iNumber].iSize3R.Length();
    len += (*iContainer.iArrayGPRS)[iNumber].iSize4R.Length();
    len += (*iContainer.iArrayGPRS)[iNumber].iSize5R.Length();
    len += (*iContainer.iArrayGPRS)[iNumber].iSize6R.Length();
    len += (*iContainer.iArrayGPRS)[iNumber].iSize8R.Length();

    len += 63; // add length of hardcoded strings (CETAK) 58+5
    }
    else
    len += 67; // add length of hardcoded strings (MODUPLOAD) 58+9

    outLine = HBufC8::NewLC(1000);

    // must use HTTP 1.0 unless you want to do a lot of coding
    //outLine->Des().Copy(_L8("POST http://111.222.333.444:8080/symbianh...ler_upload.php HTTP/1.1\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: "));
    outLine->Des().Copy(_L8("POST /symbianhandler/sHandler_upload.php HTTP/1.1\r\nHost: 111.222.333.444:8080\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: "));
    outLine->Des().AppendNum(len);
    outLine->Des().Append(_L8("\r\n\r\n"));

    iSocket.Write(outLine->Des(),iTranStatus);
    User::WaitForRequest(iTranStatus);

    // output account and password so they get URL Encoded
    outLine->Des().Zero();
    outLine->Des().Append(_L8("unm="));
    outLine->Des().Append((*iContainer.iArrayGPRS)[iNumber].iUsername);
    outLine->Des().Append(_L8("&pwd="));
    outLine->Des().Append((*iContainer.iArrayGPRS)[iNumber].iPassword);
    outLine->Des().Append(_L8("&ttl="));
    outLine->Des().Append((*iContainer.iArrayGPRS)[iNumber].iName);
    outLine->Des().Append(_L8("&alb="));
    outLine->Des().Append((*iContainer.iArrayGPRS)[iNumber].iAlbum);
    outLine->Des().Append(_L8("&sub="));
    if((*iContainer.iArrayGPRS)[iNumber].iLocation.Length()>0)
    outLine->Des().Append(_L8("CETAK"));
    else
    outLine->Des().Append(_L8("MODUPLOAD"));
    outLine->Des().Append(_L8("&2R="));
    outLine->Des().Append((*iContainer.iArrayGPRS)[iNumber].iSize2R);
    outLine->Des().Append(_L8("&3R="));
    outLine->Des().Append((*iContainer.iArrayGPRS)[iNumber].iSize3R);
    outLine->Des().Append(_L8("&4R="));
    outLine->Des().Append((*iContainer.iArrayGPRS)[iNumber].iSize4R);
    outLine->Des().Append(_L8("&5R="));
    outLine->Des().Append((*iContainer.iArrayGPRS)[iNumber].iSize5R);
    outLine->Des().Append(_L8("&6R="));
    outLine->Des().Append((*iContainer.iArrayGPRS)[iNumber].iSize6R);
    outLine->Des().Append(_L8("&8R="));
    outLine->Des().Append((*iContainer.iArrayGPRS)[iNumber].iSize8R);
    outLine->Des().Append(_L8("&trx="));
    outLine->Des().Append((*iContainer.iArrayGPRS)[iNumber].iUniqueID);
    outLine->Des().Append(_L8("&hex="));

    iSocket.Write(outLine->Des(),iTranStatus);
    User::WaitForRequest(iTranStatus);

    while(iTranStatus == KErrNone /*&& (fileSize-pos>512)*/ )
    {
    outLine->Des().Zero();
    err = exfile.Read(outLine->Des(),512);

    if (outLine->Des().Length() == 0) break;

    iSocket.Write(outLine->Des(), iTranStatus);
    User::WaitForRequest(iTranStatus);
    }

    outLine->Des().Zero();
    outLine->Des().Copy(_L8("\r\n"));
    iSocket.Write(outLine->Des(), iTranStatus);
    User::WaitForRequest(iTranStatus);

    CleanupStack::PopAndDestroy(outLine);
    exfile.Close();
    fs.Close();

    Read(); //Start CBTReadSendReader Active object to read response
    }

    when using:
    1. outLine->Des().Copy(_L8("POST http://111.222.333.444:8080/symbianh...ler_upload.php HTTP/1.1\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: "));
    ===> i get the response : 411 Length Required

    2. outLine->Des().Copy(_L8("POST /symbianhandler/sHandler_upload.php HTTP/1.1\r\nHost: 111.222.333.444:8080\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: "));
    ===> i get the response : 400 Bad Request

    why both of them are incorrect?

    help n TIA
    Rx-

  2. #2
    Regular Contributor
    Join Date
    Feb 2004
    Posts
    130

    Re: HTTP POST Problem

    update:

    when i send it using
    1. outLine->Des().Copy(_L8("POST http://111.222.333.444:8080/symbian...dler_upload.php HTTP/1.1\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: "));

    but without
    1. "exfile.Size(len);" and
    2. looping sending data "while blalbalba"

    i can hit the server.

    i assume that it is because either
    1. the length is not correct (i checked it and it is correct) or
    example:
    POST http://111.222.333.444.8080/symbianh...ler_upload.php HTTP/1.1
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 1914

    unm=abcde&pwd=abcde&ttl=garis2.jpg&alb=330&sub=MODUPLOAD&2R=&3R=&4R=&5R=&6R=&8R=&trx=2205200619422268750357927000633472&hex=ffd8ffe000104a46494600010101012c012c0000ffdb004300080606070605080707070909080a0c140d0c0b0b0c1912130f141d1a1f1e1d1a1c1c20242e2720222c231c1c2837292c30313434341f27393d38323c2e333432ffdb0043010909090c0b0c180d0d1832211c213232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232ffc00011080066006703012200021101031101ffc4001f0000010501010101010100000000000000000102030405060708090a0bffc400b5100002010303020403050504040000017d01020300041105122131410613516107227114328191a1082342b1c11552d1f02433627282090a161718191a25262728292a3435363738393a434445464748494a535455565758595a636465666768696a737475767778797a838485868788898a92939495969798999aa2a3a4a5a6a7a8a9aab2b3b4b5b6b7b8b9bac2c3c4c5c6c7c8c9cad2d3d4d5d6d7d8d9dae1e2e3e4e5e6e7e8e9eaf1f2f3f4f5f6f7f8f9faffc4001f0100030101010101010101010000000000000102030405060708090a0bffc400b51100020102040403040705040400010277000102031104052131061241510761711322328108144291a1b1c109233352f0156272d10a162434e125f11718191a262728292a35363738393a434445464748494a535455565758595a636465666768696a737475767778797a82838485868788898a92939495969798999aa2a3a4a5a6a7a8a9aab2b3b4b5b6b7b8b9bac2c3c4c5c6c7c8c9cad2d3d4d5d6d7d8d9dae2e3e4e5e6e7e8e9eaf2f3f4f5f6f7f8f9faffda000c03010002110311003f00f7fa28a2800a28a2800a28a2800a28a2800a28a2800a28a2800a28a2800a28a2800a28a2800a28a2800a28a2800a28a2800a28a2800a28a2800a28a2800a28aaf7d7b169f6725d4c93bc698c8820799ce481c2202c7af61c75e9401628ae7ffe132d2ffe7d75cffc115eff00f19ad4d37538355b769ede3bb44572845d5a4b6ed9c03c2c8aa48e7ae31d7d0d005ca28a2800a28a2800a28a2800a28a2800a28a2800a28a2800a28a2800a28a2800a28a2800a28a2800a28a2800a28a2800a28a2800a28a2800a28a2800a28a2800a28a2800a28a2800a28a2800a28a2800a28a2800a28a2800a28a2800a28a2800a28a2800a28a2800a28a2800a28a2800a28a2800a28a2800a28a2800a28a2803ffd9

    2. the http body is too long. (there is a boundary from the server).

    any clue?
    FYI, using Apache/1.3.31 (Win32) PHP/5.0.0
    Rx-

  3. #3
    Nokia Developer Expert
    Join Date
    Jul 2003
    Location
    Vancouver, Canada
    Posts
    220

    Lightbulb Re: HTTP POST Problem

    My advice would be to use Ethereal ( http://www.ethereal.com/ ) to monitor your network traffic between your application and your server. It decodes the HTTP messages and will help you spot formating problems and to see the HTTP responses of your server. It will even help you spot if your server tears down the connection since it thinks your application is a 'bad client' due to poorly formated HTTP Post.

    Hope this helps

  4. #4
    Regular Contributor
    Join Date
    Feb 2004
    Posts
    130

    Re: HTTP POST Problem

    hi billbonney,

    thx for ur advice.
    the problem is in the connection of the network. when i change the card (gsm sim card), it all works well.

    Rx-

Similar Threads

  1. Nokia 3510i http request problem
    By icrni in forum Mobile Java Networking & Messaging & Security
    Replies: 3
    Last Post: 2004-11-18, 15:29
  2. HTTP Connection problem with real series 40 device
    By pagadi in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2004-06-17, 09:28
  3. POST broken on http 1.1
    By rsmithh in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2004-03-26, 03:59
  4. HTTP POST, sending data, any idea how to fetch in PHP?
    By imarenic in forum Mobile Java Networking & Messaging & Security
    Replies: 4
    Last Post: 2003-11-13, 22:05
  5. Need help! HTTP or TCP/IP Connection possible thru serial cable? (long post)
    By kurisu-chan in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2003-07-23, 04:51

Posting Permissions

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