×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    17

    Writing bytes to send as a http post content

    Hi @ all,

    I have implemented a http post request with MHTTPDataSupplier. I have set up the uri and method sucessfully, but I have a problem with the content. Not with sending it, but with customize it, though.
    Since I'm using MHTTPDataSupplier, I have a HBufC8 class attribut, which contains the content of the http post. but here is my problem, I don't want to specify the "String" of the content, but all the single bytes.

    I managed to specifiy some bytes, which will never change, with

    Code:
      TChar c0 = 0x0;
      TBuf8<170> t;
      t.AppendFormat(_L8("%c"),c0);
      // ...
    --> Result: The byte is 0.

    But my actuall problem is when I want to write the Hex values of an integer. If I use
    Code:
      t.AppendFormat(_L8("%d"), 15);
    it appends the 15 to the "string", but in the byte stream should now stand "00 00 00 0F". But it doesn't.

    If I use

    Code:
      t.AppendNum(aInt, EHex);
    it writes the hex value to the string, not to the bytes...


    I have searched but haven't found a answer to that. Anyone has a Idea how to write that raw data?

    Thanks!!!
    Last edited by greumatt; 2009-01-30 at 02:22.
    "Rumor has it that, when they shut down the IBM 7094 at MIT in 1973, they found a low-priority process that had been submitted in 1967 and had not yet been run."

  2. #2
    Registered User
    Join Date
    Jan 2007
    Posts
    282

    Re: Writing bytes to send as a http post content

    If i understand your query right then i think you are asking how to convert a TInt into a descriptor containing its binary content i.e for a TInt = 15 you want a corrosponding TDesC8 = Hex( 00 15 )


    Using descriptors its trivial to do so. Please follow the code below

    Code:
    TInt anyint=15;
    TPtrC8 binarydes( (TUint8*) &anyint, sizeof(anyint));
    now desriptor binarydes will contain integer in its binary form which you are write to your MHTTPDataSupplier interface implementation.

    Hope that helps,
    Regards,
    VJ

  3. #3
    Registered User
    Join Date
    May 2008
    Posts
    17

    Re: Writing bytes to send as a http post content

    Hi vaibhavjain,

    thanks for your reply! It almost did the trick. With your code I can write now the Binary Data but there seems to be a aligning problem.

    For big values, e.g.

    TInt myInt = 12345;

    The result is 39 30 in my bytestream... but I should be 30 39!

    Is there any way to specifiy the byte order?!

    Thanks again,

    Matt
    "Rumor has it that, when they shut down the IBM 7094 at MIT in 1973, they found a low-priority process that had been submitted in 1967 and had not yet been run."

  4. #4
    Registered User
    Join Date
    May 2008
    Posts
    17

    Re: Writing bytes to send as a http post content

    Okay I figured it out by now.

    I changed the byteorder by using

    TUint32 myInt = 12345;
    myInt = ByteOrder::Swap32(myInt);

    and then build the pointer like you mentioned. Thanks again vaibhavjain!
    "Rumor has it that, when they shut down the IBM 7094 at MIT in 1973, they found a low-priority process that had been submitted in 1967 and had not yet been run."

Similar Threads

  1. HTTP POST using Nokia 7650
    By mikael_kinnunen in forum Mobile Java Networking & Messaging & Security
    Replies: 8
    Last Post: 2008-08-19, 23:32
  2. HTTP Post problem on Symbian 9.2 - TCP stuck?
    By bgenady in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2008-08-04, 19:33
  3. Problems with HTTP POST
    By Summerman in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2006-11-27, 09:25
  4. Does Vodafone UK wap gateway supports HTTP POST?
    By jessicay in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2004-07-06, 15:27
  5. 7650 J2ME/MIDP HTTP Post
    By cwalkinshaw in forum Mobile Java General
    Replies: 2
    Last Post: 2002-10-23, 10:12

Posting Permissions

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