×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    4

    WAP upload / Content-Type header is lost at WAP gateway

    Dear Friends,

    I am trying to upload some content to a WWW server from my Series 60 emulator using the WAP protocol stack. I need to use the WSP POST method, since the contect is quite big. My problem is, that the Headers I provide when I create a WSP transaction are lost at the WAP gateway. This is a major problem, since the WWW server needs the
    Content-Type header to be able to process the query. If you could give me some hints on how to resolve this error, I would be greatfull.

    Here is what I do in detail:

    1.) THE SOURCE CODE

    In the Series 60 application, before the WSP transaction is created,
    I set the Content-Type header:

    ...
    RWAPConn::TMethod Method = RWAPConn::EPost;
    _LIT(KURI,"http://192.168.0.6/test.php"
    _LIT8(KHeaders,"Content-Type: application/x-www-form-urlencoded"
    _LIT8(KBdy,"param1=gyula&param2=76"

    TInt err = iWspConn->CreateTransaction(Method, KURI, KHeaders, KBdy, *iWspTrans);
    ...

    2.) AT THE WAP GATEWAY

    The WAP gateway receives this header, but returns an error message: "WARNING: Skipping faulty header."
    I have tryed three different wap gateways (Ophelia, Kannel, WAP-Gate), but none of them reognized the
    'Content-Type' header field. You can take a look at the log of the Kannel WAP gateway:

    2003-01-02 00:45:32 [1] DEBUG: WSP: machine 0x1001b000, state CONNECTED, event TR-Invoke.ind
    2003-01-02 00:45:32 [1] DEBUG: WSP: method 8, state NULL_METHOD, event TR-Invoke.ind
    2003-01-02 00:45:32 [1] DEBUG: WSP: decoding headers:
    2003-01-02 00:45:32 [6] DEBUG: WTP 8: New state INVOKE_RESP_WAIT
    2003-01-02 00:45:32 [1] DEBUG: Octet string at 0x10016060:
    2003-01-02 00:45:32 [1] DEBUG: len: 47
    2003-01-02 00:45:32 [1] DEBUG: size: 48
    2003-01-02 00:45:32 [1] DEBUG: immutable: 0
    2003-01-02 00:45:32 [1] DEBUG: data: 43 6f 6e 74 65 6e 74 2d Content-
    2003-01-02 00:45:32 [1] DEBUG: data: 54 79 70 65 3a 20 61 70 Type: ap
    2003-01-02 00:45:32 [1] DEBUG: data: 70 6c 69 63 61 74 69 6f plicatio
    2003-01-02 00:45:32 [1] DEBUG: data: 6e 2f 78 2d 77 77 77 2d n/x-www-
    2003-01-02 00:45:32 [1] DEBUG: data: 66 6f 72 6d 2d 75 72 6c form-url
    2003-01-02 00:45:32 [1] DEBUG: data: 65 6e 63 6f 64 65 64 encoded
    2003-01-02 00:45:32 [1] DEBUG: Octet string dump ends.
    2003-01-02 00:45:32 [1] WARNING: Skipping faulty header.
    2003-01-02 00:45:32 [1] DEBUG: WSP 4/8: New method state HOLDING
    2003-01-02 00:45:32 [1] DEBUG: WSP: method 8, state HOLDING, event Release
    2003-01-02 00:45:32 [15] DEBUG: HTTP: Opening connection to `192.168.0.6:80'.

    3.) AT THE WWW SERVER

    This is what the webserver receives from the WAP gateway. AS you can see, the HTTP header does not contain the Content-Type header field:

    POST /test.php HTTP/1.1
    Host: 192.168.0.6
    Accept-Charset: ISO-8859-1
    Accept-Charset: ISO-8859-2
    Accept-Charset: UTF-8
    X_Network_Info: 192.168.0.110
    X-WAP-Client-SDU-Size: 1400
    Via: WAP/1.1 inside (Kannel/1.1.4)
    X-WAP-Gateway: Kannel/1.1.4
    X-WAP-Session-ID: 0
    Content-Length: 22

    param1=gyula&param2=76


    I have spent a lot of time on trying to find a solution. I have experimented with differnet content-types, and tryed different WSP methods. Unfortunately I cannot get a header through.


    Best Regards,

    Gyula Rabai
    Ozeki Informatics Ltd.
    Hungary

  2. #2
    Registered User
    Join Date
    Feb 2004
    Posts
    1
    Rabai,

    From some reading I've found it looks like the headers shouldn't be put as text but use byte values instead.

    Here is what I've found:

    headers.Zero();
    // Content-type first in POST
    // we are sending the equivalent of a form submittion
    headers.Append( 0x12 );
    // Accept: */*
    headers.Append( 0x80 );
    headers.Append( 0x80 );
    // Content-length:
    headers.Append( 0x8d );
    MakeContentLength( pPostData->Length(), headers );

    The makeContentLength code reads as follow:

    void MakeContentLength(TUint size, TDes8& header)
    {
    TChar bytes;
    if (size>0xffffff) {
    bytes=4;
    } else if(size>0xffff) {
    bytes=3;
    } else if (size>0xff) {
    bytes=2;
    } else {
    bytes=1;
    }

    header.Append(bytes);

    TChar enc[4];
    TUint mask=256;
    TUint mod=0;
    TInt i=bytes;
    --i;
    while (i>=0) {
    mod=size % mask;
    size-=mod;
    if (mask>256) mod/=(mask/256);
    enc[i]=mod;
    mask*=256;
    --i;
    }
    for (i=0; (TChar)i<bytes; i++) {
    header.Append(enc[i]);
    }
    }

    Unfortunately, I can't assure you that works perfectly as I'm hitting on a different problem on the same subject: I can't get the connection between my device (or emulator) and the WAP Gateway.
    I would appreciate if you can share the code you use open the connection. I'm trying to do the same thing than you (POST to a web server).

    Cheers,
    Denis

  3. #3
    Registered User
    Join Date
    Aug 2003
    Location
    Oulu, Finland
    Posts
    1,122
    The header CAN be binary-encoded but doesn't have to. For example,
    Code:
    _LIT8(KHeaders,"application/x-www-form-urlencoded\0");
    should work as well. Notice that there is no header name provided for the content-type (it's implicit), and there is a nul byte at the end.

    Lauri

Posting Permissions

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