×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    69

    how to get multi set-cookie in HTTP response header?

    My application need to build a session with web server. After I post something to the server, it returns me 2 cookies (by two set-cookie headers) in one response message. I need get them and send them to the server in my next request.

    The question is it seems by HTTP API, only the first cookies can be retrieved. Is this what S60 SDK V2 can do now? If you have experience, please give some comments and suggestion. This is important to my work on hand. Thank you very much.

  2. #2
    Registered User
    Join Date
    Apr 2008
    Posts
    69

    Re: how to get multi set-cookie in HTTP response header?

    Anyone help me?
    Last edited by xuelanding; 2008-06-25 at 09:59.

  3. #3
    Super Contributor
    Join Date
    Nov 2004
    Location
    Wiltshire, UK
    Posts
    3,644

    Re: how to get multi set-cookie in HTTP response header?

    Can't you iterate over the headers using RHTTPHeaders::Fields and get the cookie fields that way?
    Download Symbian OS now! [url]http://developer.symbian.org[/url]

  4. #4
    Registered User
    Join Date
    Apr 2008
    Posts
    69

    Re: how to get multi set-cookie in HTTP response header?

    I use following code to iterate the header, but only the first cookie is displayed. But from the sdk tool, I can see 2 cookies are received in the header.

    {//list all headers
    TBuf<256> fieldName16;
    TBuf<256> fieldVal16;
    RHTTPResponse resp = aTransaction.Response();
    RStringPool strP = aTransaction.Session().StringPool();
    RHTTPHeaders hdr = resp.GetHeaderCollection();
    // Get an iterator for the collection of response headers
    THTTPHdrFieldIter it = hdr.Fields();
    while (it.AtEnd() == EFalse)
    {
    // Get name of next header field
    RStringTokenF fieldName = it();
    RStringF fieldNameStr = strP.StringF(fieldName);
    // Get the field value
    THTTPHdrVal fieldVal;
    if (hdr.GetField(fieldNameStr,0,fieldVal) == KErrNone)
    {
    const TDesC8& fieldNameDesC = fieldNameStr.DesC();
    fieldName16.Copy(fieldNameDesC.Left(256));
    switch (fieldVal.Type())
    {
    case THTTPHdrVal::KTIntVal:
    iObserver.ClientEvent(fieldName16);//function to display the field name.


    break;
    case THTTPHdrVal::KStrFVal:
    {
    RStringF fieldValStr = strP.StringF(fieldVal.StrF());
    const TDesC8& fieldValDesC = fieldValStr.DesC();
    fieldVal16.Copy(fieldValDesC.Left(256));
    iObserver.ClientEvent(fieldName16);
    iObserver.ClientEvent(fieldVal16);

    }
    break;
    case THTTPHdrVal::KStrVal:
    {
    RString fieldValStr = strP.String(fieldVal.Str());
    const TDesC8& fieldValDesC = fieldValStr.DesC();
    fieldVal16.Copy(fieldValDesC.Left(256));
    iObserver.ClientEvent(fieldName16);
    iObserver.ClientEvent(fieldVal16);
    }
    break;
    case THTTPHdrVal::KDateVal:
    {
    TDateTime date = fieldVal.DateTime();
    TBuf<40> dateTimeString;
    TTime t(date);
    // t.FormatL(dateTimeString,KDateFormat);
    iObserver.ClientEvent(fieldName16);
    }
    break;
    default:
    //Printf(_L("%S: <unrecognised value type>\n"), &fieldName16);
    break;
    }
    }
    // Advance the iterator to get the next field
    ++it;
    }
    }//list all headers

Similar Threads

  1. How to set proxy in an HTTP request
    By gigglie in forum Symbian
    Replies: 1
    Last Post: 2008-05-23, 10:26
  2. How to retrieve entire HTTP response into a buffer?
    By pavarang in forum Symbian Networking & Messaging (Closed)
    Replies: 3
    Last Post: 2008-04-18, 21:18
  3. 302 redirection response header missing
    By morost in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2007-03-30, 16:24
  4. nokia 7210 modem via IR doesn't work !
    By oussamaaiadi in forum PC Suite API and PC Connectivity SDK
    Replies: 1
    Last Post: 2003-03-06, 10:46
  5. HTTP header
    By xrsu in forum General Messaging
    Replies: 1
    Last Post: 2002-12-11, 08:11

Posting Permissions

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