×

Discussion Board

Results 1 to 11 of 11

Hybrid View

  1. #1
    Registered User
    Join Date
    Sep 2008
    Location
    Vancouver, Canada
    Posts
    588

    Correct way to use HTTP POST

    Hello,

    I have two urls. The first one is something like
    Code:
    http://10.10.10.10/page1.php?usr=123&pwd=000
    Respose of this is an inputbox, a button (on browser) and an action url something like
    Code:
    http://11.11.11.11/page2.php
    When the user hits the second link, the value entered in inputbox should along with request. Response to the second url is a
    string response.

    The issue:
    If i am not wrong, the first request would be http GET type and second would be http POST type. I am getting correct response on
    making the first request but second request is not giving the correct response from the server if i do this is code. However if i use the browser manually, the response is correct.
    I also tried encoding the url as well but still not getting the correct response.

    Any pointers to this?

  2. #2
    Registered User
    Join Date
    Sep 2008
    Location
    Vancouver, Canada
    Posts
    588

    Re: Correct way to use HTTP POST

    Also i am using the following code to encode the url:

    I am not sure if this encodes in utf-8 format. Do you think this is correct?

    Code:
    HBufC* CWebClient::UrlEncodeL(TDes& aUrl)
    {
      _LIT(KFormatCode, "%%%02x");
      
      if (!aUrl.Length())
      {
         return NULL;
      }
      TBufC<100> sDontEncode = _L("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!-_.()*;/?:@&=+$[]!\\'()~");
    
     // Alloc to the maximum size of URL if every char are encoded
      HBufC *sEncoded = HBufC::NewLC(aUrl.Length() * 3);
    
      // Parse a the chars in the url
      for (TInt i=0; i<aUrl.Length(); i++)
      {
         TChar cToFind = aUrl[i];
         if (KErrNotFound == sDontEncode.Locate(cToFind) )
         {
            // Char not found encode it.
            TUint c = (TUint) cToFind;
            sEncoded->Des().AppendFormat(KFormatCode, c);
         }
         else
         {
            // char found just copy it
            sEncoded->Des().Append(cToFind);
         }
      }
    
      // Reallocate to the real size of the encoded url.
      sEncoded->ReAllocL(sEncoded->Length());
    
      return sEncoded;
    }

  3. #3
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    4,089

    Re: Correct way to use HTTP POST

    What happens if you make the second request to be GET as well.

  4. #4
    Registered User
    Join Date
    Sep 2008
    Location
    Vancouver, Canada
    Posts
    588

    Re: Correct way to use HTTP POST

    But how do i pass the pin number in that case which is entered in the inputbox?

  5. #5
    Registered User
    Join Date
    Sep 2008
    Location
    Vancouver, Canada
    Posts
    588

    Re: Correct way to use HTTP POST

    I tried the second url as GET by setting pin: 00000000000000 in headers. The response is still not correct because the request to server is not correct.

  6. #6
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    4,089

    Re: Correct way to use HTTP POST

    In the same way it is done in first request(http://11.11.11.11/page2.php?boxvalue=1234). When user hits the second url, you can internally append the box value.

  7. #7
    Registered User
    Join Date
    Sep 2008
    Location
    Vancouver, Canada
    Posts
    588

    Re: Correct way to use HTTP POST

    No this is incorrect. I tried this as well and the result is same. I am getting the following error message from server alongwith some html

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

  8. #8
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    India
    Posts
    1,174

    Re: Correct way to use HTTP POST

    You can check the request (with headers) in Fiddler for both correct/incorrect cases and compare the difference.

    If i am not wrong, the first request would be http GET type and second would be http POST type.
    Yes, your first request should be GET and second should be POST.

Similar Threads

  1. Post values to server using HTTP POST
    By ramtrg in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2011-08-23, 08:49
  2. Post values to server using HTTP POST
    By ramtrg in forum Symbian Networking & Messaging (Closed)
    Replies: 4
    Last Post: 2011-08-22, 11:34
  3. http post again and again
    By linzhiji in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2011-05-05, 06:43
  4. Sending a POST message to PHP - HTTP/1.0 works, but HTTP/1.1 doesn't?
    By anummiah in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2008-05-13, 16:53
  5. HTTP Client - Synchronous HTTP POST Calls?
    By symbian_ravi in forum Symbian Networking & Messaging (Closed)
    Replies: 5
    Last Post: 2006-04-16, 11: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
  •  
×