×

Discussion Board

Results 1 to 14 of 14
  1. #1
    Registered User
    Join Date
    Sep 2008
    Location
    Vancouver, Canada
    Posts
    588

    HTTP-Core 4 panic while reading cookies

    Hi,

    Please consider this code:

    Code:
    			RHTTPResponse resp1 = aTransaction.Response();
    			RStringPool strP = aTransaction.Session().StringPool();
    			RHTTPHeaders hdr = resp1.GetHeaderCollection();
    			THTTPHdrFieldIter it = hdr.Fields();
    			TBuf<512> fieldName16;
    			TBuf<512> fieldVal16;
    
    			while (it.AtEnd() == EFalse)
    				{
    				// Get the name of the next header field <br>
    				RStringTokenF fieldName = it();
    				RStringF fieldNameStr = strP.StringF(fieldName);
    
    				// Check it does indeed exist
    				THTTPHdrVal fieldVal;
    				if (hdr.GetField(fieldNameStr, 0, fieldVal) == KErrNone)
    					{
    					RStringF wwwCookie = strP.StringF(HTTP::ESetCookie,	RHTTPSession::GetTable());
    					TInt mycookieCount = hdr.FieldPartsL(wwwCookie);
    
    					if (fieldNameStr == wwwCookie)
    						{
    						RStringF nameValStr;
    						RStringF valueValStr;
    
    						// Check the cookie name and value
    						RStringF name = strP.StringF(HTTP::ECookieName,	RHTTPSession::GetTable());
    						RStringF value = strP.StringF(HTTP::ECookieValue, RHTTPSession::GetTable());
    
    						THTTPHdrVal nameVal, valueVal;
    						
    						if (hdr.GetParam(wwwCookie, name, nameVal) == KErrNone)
    							{
    							nameValStr = strP.StringF(nameVal.StrF());
    							fieldName16.Copy(nameValStr.DesC());
    							}
    						if (hdr.GetParam(wwwCookie, value, valueVal) == KErrNone)
    							{
    							valueValStr = strP.StringF(valueVal.StrF());
    							fieldVal16.Copy(valueValStr.DesC());
    							}
    
    						// Create a cookie object with name, value and URI and save
    						// it as a file (for example, to app. private directory)
    						// URI can be obtained with:						
    						 //const TUriC8& requestUri = aTransaction.Request().URI();
    						}
    					}
    				// Advance the iterator
    				++it;
    				}
    			break;
    I am using this code to read incoming cookies. The application crashes at the pointed line. No idea what is going wrong in here.

    Please suggest.

    Thanks

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,567

    Re: HTTP-Core 4 panic while reading cookies

    You may want to find out which part of the line fails (nameVal.StrF() may or may not die already in itself).
    Unfortunately the on-line documentation is no more, but according to http://www.developer.nokia.com/Commu...P-CORE-6-Panic, it seems to be a very different panic than what happens in the red line.
    Ah, yes, SymLab still has the docs: http://www.symlab.org/main/documenta...B9652A172.html, based on that you may want to check if MHFRunError gets invoked, and how.

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

    Re: HTTP-Core 4 panic while reading cookies

    I know HTTP Core 4 means Mismatch between header's type and its attempted use. But can't figure out what is wrong. The response is for a http GET request. Do we have to set the appropriate headers before making the http request?
    Right now the following headers are set:

    SetHeaderL( hdr, HTTP::EUserAgent, KUserAgent );
    SetHeaderL( hdr, HTTP::EAccept, KAccept );

  4. #4
    Registered User
    Join Date
    Jan 2005
    Location
    Italy
    Posts
    639

    Re: HTTP-Core 4 panic while reading cookies

    raj8nokiaforum asked about HTTP-Core-4, so "Mismatch between header's type and its attempted use. " :-)
    maybe something related to Str() and StrF() ?
    http://www.developer.nokia.com/Commu...request-header
    http://www.developer.nokia.com/Commu...99-HTTP-core-4

    anyway we should do something for missing online symbian docs... so that we don't redirect people on external links....

    regards
    pg

    EDIT: sorry, posted just after raj8nokiaforum reply

  5. #5
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,567

    Re: HTTP-Core 4 panic while reading cookies

    Sorry, I absolutely misread the title for 6. My only excuse is that the sun recently started shining on my display.
    Are you following some existing code? Like http://www.developer.nokia.com/Commu...ymbian_C%2B%2B? Are there any modifications?

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

    Re: HTTP-Core 4 panic while reading cookies

    Yes i am following the same without any modification. The same code is giving this panic. And
    My only excuse is that the sun recently started shining on my display.
    was funny. Certainly brought smile on my face

    pavarang also suggested good links. I will try them as well and will get back.

  7. #7
    Registered User
    Join Date
    Jan 2005
    Location
    Italy
    Posts
    639

    Re: HTTP-Core 4 panic while reading cookies

    Quote Originally Posted by raj8nokiaforum View Post

    pavarang also suggested good links. I will try them as well and will get back.
    i have a new one! :-D
    in this article
    http://www.developer.nokia.com/Commu...ymbian_C%2B%2B

    they check the http header val type:

    Code:
    if (nameVal.Type() == THTTPHdrVal::KStrFVal)
                            {
                                strF = nameVal.StrF();
                                nameValStr = strP.StringF(strF); // this is the cookie's name
                            }
                            else if (nameVal.Type() == THTTPHdrVal::KStrVal)
                            {
                                str = nameVal.Str(); // this is the cookie's name
                            }

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

    Re: HTTP-Core 4 panic while reading cookies

    Well certainly the problem is with using classes with F and without F at the end. Is there any way to find out or set in advance what type of value or name we want? I mean where shall we use RStringF and where RString and many other such classes.

  9. #9
    Registered User
    Join Date
    Jan 2005
    Location
    Italy
    Posts
    639

    Re: HTTP-Core 4 panic while reading cookies

    well... checking the type as in
    Code:
    nameVal.Type() == THTTPHdrVal::KStrFVal
    isn't enough?
    there are other values defined in THTTPHdrVal:
    http://www.symlab.org/main/documenta...9FEDBD5B3.html
    e.g.
    Code:
    enum	THTTPValType { KTIntVal = 0x00, KStrVal = 0x01, KDateVal = 0x02, KStrFVal = 0x03, KNoType = 0x04 }
    otherwise i have no ideas, sorry
    pg

  10. #10
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,567

    Re: HTTP-Core 4 panic while reading cookies

    THTTPHdrVal::Type?

    For the F, non-F, that is about case sensitivity (f=folding, refer to descriptor comparison methods like Compare, CompareF and CompareC for reading about comparison modes). That part is certainly not dynamic, for example HTTP header names must use F, as they are declared case-insensitive in the RFC (http://www.w3.org/Protocols/rfc2616/...c4.html#sec4.2)

    EDIT: oh, I see #9 now

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

    Re: HTTP-Core 4 panic while reading cookies

    Thank you guys. Problem solved. Now that was the reading part. Now I will have send the same cookie to server as well.

    As i mentioned i had set the header fields corresponding to cookies. Now while sending the cookie i have two options to set the headers:

    Code:
    	 SetHeaderL(hdr, HTTP::ECookie, KAtext);
    	 SetHeaderL(hdr, HTTP::ECookieName, KAtext);
    	 SetHeaderL(hdr, HTTP::ECookieValue, KAtext);
    and

    Code:
    		SetHeaderL(hdr, HTTP::ESetCookie, KAtext);
    		SetHeaderL(hdr, HTTP::ECookieName, iCookieName);
    		SetHeaderL(hdr, HTTP::ECookieValue, iCookieValue);
    Shall i keep the headers same as while making http request or change them to like the second one just above?

  12. #12
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,567

    Re: HTTP-Core 4 panic while reading cookies

    By the original intent, cookies are small pieces of data what servers send to you, you store them, and when you talk to the same server next time, you send them, so the server can recognize/remember you. Thus a constant cookie does not make much sense, it is usable for demonstration/example code only.

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

    Re: HTTP-Core 4 panic while reading cookies

    yes you are right but in the second section i am sending the same cookie back to the server.

    here i am only confused about which header to use HTTP:ECookie or HTTP:ESetCookie or shall i not alter the header type at all?

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

    Re: HTTP-Core 4 panic while reading cookies

    Ok so header types has to be remain the same, we can post the cookie in the form itself. Thats how it worked for me.

Similar Threads

  1. HTTP CORE 6 Panic
    By yanamaddinaveen in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2011-12-05, 11:39
  2. HTTP - CORE 6 error
    By rati2010 in forum Symbian C++
    Replies: 6
    Last Post: 2009-09-03, 09:34
  3. Replies: 20
    Last Post: 2008-12-24, 01:33
  4. [moved] 3rd Party Application reading cookies
    By tej007 in forum Symbian Networking & Messaging (Closed)
    Replies: 8
    Last Post: 2008-10-16, 13:32
  5. CHTTPFormEncoder and HTTP-CORE 10 Panic
    By Dexterp37 in forum Symbian Networking & Messaging (Closed)
    Replies: 7
    Last Post: 2006-08-11, 18:38

Posting Permissions

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