×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Regular Contributor
    Join Date
    Mar 2006
    Location
    India
    Posts
    138

    Angry [moved] Why In header collection RHTTPResponse for field Set-Cookie is Cookie only?

    Hi,
    While receving the response from the server via HTTP client APIs, when I look value for field Set-Cookie in
    RHTTPResponse, that is set "Cookie" only?
    But when I see HTTP client generated logs httptransporthandler.txt I see value for Set-Cookie is a some different string.
    I have tried both RHTTPResponse::GetRawField()
    RHTTPResponse::GetField()

    Plz help
    Thanks
    Regards
    Anand

  2. #2
    Regular Contributor
    Join Date
    Mar 2006
    Location
    India
    Posts
    138

    Re: Why In header collection RHTTPResponse value for field Set-Cookie is Cookie only?

    Hi
    Do need to implement MHTTPFilter to access Set-Cookie field in
    Response header.

    Thanks

  3. #3
    Registered User
    Join Date
    Sep 2008
    Posts
    45

    Re: Why In header collection RHTTPResponse value for field Set-Cookie is Cookie only?

    Hi,

    I have the same question. Did you find a solution to this problem??

    Maria

  4. #4
    Regular Contributor
    Join Date
    Mar 2006
    Location
    India
    Posts
    138

    Thumbs up Re: Why In header collection RHTTPResponse value for field Set-Cookie is Cookie only?

    Quote Originally Posted by mariadlangeles View Post
    Hi,

    I have the same question. Did you find a solution to this problem??

    Maria

    Hi Maria,
    I think following code will solve your problem:

    // HTTP response headers have been received.

    //Check if the response header has a Cookie
    const TStringTable& sessionStringTable = RHTTPSession::GetTable ( );
    RStringF cookieField = strP.StringF (HTTP::ESetCookie,sessionStringTable );

    RHTTPHeaders respHeader = resp.GetHeaderCollection ( );

    THTTPHdrVal headerValue;

    TInt retVal = respHeader.GetField (cookieField, 0, headerValue );
    if (retVal != KErrNotFound )
    {
    if (headerValue.StrF ( )== strP.StringF (HTTP::ECookie,
    RHTTPSession::GetTable ( ) ) )
    {

    TInt parts = respHeader.FieldPartsL (cookieField );

    // Get all the cookies name value pairs.
    for (TInt index = 0; index < parts; index++ )
    {
    RStringF strCookieNameId = strP.StringF (
    HTTP::ECookieName, RHTTPSession::GetTable ( ) );

    retVal = respHeader.GetParam (cookieField,
    strCookieNameId, headerValue, index );

    if (retVal != KErrNotFound )
    {
    HBufC8* cookieNameString= NULL;

    switch (headerValue.Type ( ) )
    {
    case THTTPHdrVal::KStrFVal:
    {
    cookieNameString = HBufC8::NewLC (headerValue.StrF().DesC().Length ( ) );
    cookieNameString->Des().Copy (headerValue.StrF().DesC ( ) );
    }
    break;
    case THTTPHdrVal::KStrVal:
    {
    cookieNameString = HBufC8::NewLC (headerValue.Str().DesC().Length ( ) );
    cookieNameString->Des().Copy (headerValue.Str().DesC ( ) );
    }
    break;
    default:
    //if type of Cookie string is unknown
    //User::Leave(KErrGeneral);
    break;
    }

    RStringF strCookieValueID = strP.StringF (HTTP::ECookieValue, sessionStringTable );

    // Read the COOKIE VALUE.
    retVal = respHeader.GetParam (cookieField,
    strCookieValueID, headerValue, index );

    if (retVal != KErrNotFound )
    {
    HBufC8* cookieValString= NULL;

    switch (headerValue.Type ( ) )
    {
    case THTTPHdrVal::KStrFVal:
    {
    cookieValString = HBufC8::NewLC (headerValue.StrF().DesC().Length ( ) );

    cookieValString->Des().Copy (headerValue.StrF().DesC ( ) );
    }
    break;
    case THTTPHdrVal::KStrVal:
    {
    cookieValString = HBufC8::NewLC (headerValue.Str().DesC().Length ( ) );

    cookieValString->Des().Copy (headerValue.Str().DesC ( ) );
    }
    break;
    default:
    {
    }
    break;
    }

    //As only first cookie is required
    if (index == 0 )
    {
    CHTTPTransport* httpTransport = static_cast<CHTTPTransport*>(&(CNetworkTransport::GetReference( )));
    CleanupStack::PushL(httpTransport);

    httpTransport->SetCookie (cookieNameString, cookieValString );

    CleanupStack::Pop(httpTransport);
    httpTransport = NULL;
    }

    CleanupStack::Pop (cookieValString );
    CleanupStack::Pop (cookieNameString );
    }
    else
    {
    }
    }
    else
    {
    }
    }//End of for loop
    }
    else
    {
    }
    }

  5. #5
    Registered User
    Join Date
    Sep 2008
    Posts
    45

    Re: Why In header collection RHTTPResponse value for field Set-Cookie is Cookie only?

    Thank you, it's help

  6. #6
    Registered User
    Join Date
    Jul 2008
    Posts
    275

    Re: Why In header collection RHTTPResponse value for field Set-Cookie is Cookie only?

    I meet the same problem and I figured out that THTTPHdrFieldIter can be used only once,if you try iterating the headers a second time ,the value of "Set-Cookie" will become "Cookie".
    So just do once can avoid this problem

    Ugly symbian BUG!!!
    ----------------------------------------
    Annotation:
    'BabyKiller' means 'A killer who is a baby',
    not 'A killer who kills baby'.

Similar Threads

  1. How can i set cookie for CBrCtlInterface
    By suojianjian11 in forum Symbian
    Replies: 0
    Last Post: 2010-07-05, 11:46
  2. HttpConnection cuts Set-Cookie header on S60 3rd
    By spietari in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2010-03-10, 14:54
  3. Set-Cookie header not found
    By a.wasilewski in forum Mobile Java Networking & Messaging & Security
    Replies: 3
    Last Post: 2009-04-27, 08:38
  4. Get server cookie. NOT in Header!
    By sandro1972 in forum Mobile Java Networking & Messaging & Security
    Replies: 14
    Last Post: 2008-07-15, 15:51
  5. how to get multi set-cookie in HTTP response header?
    By xuelanding in forum Symbian Networking & Messaging (Closed)
    Replies: 3
    Last Post: 2008-06-26, 07:40

Posting Permissions

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