httpfilters/cookie/ManagerSrc/Cookie.cpp
branchRCL_3
changeset 9 2611c08ee28e
parent 8 fa2fd8b2d6cc
child 10 73e95e652591
equal deleted inserted replaced
8:fa2fd8b2d6cc 9:2611c08ee28e
    24 #include <http/rhttpsession.h>
    24 #include <http/rhttpsession.h>
    25 #include <uri8.h>
    25 #include <uri8.h>
    26 
    26 
    27 	// User includes
    27 	// User includes
    28 #include "cookie.h"
    28 #include "cookie.h"
       
    29 #include "cookielogger.h"
    29 #include "CookieCommonConstants.h"
    30 #include "CookieCommonConstants.h"
    30 
    31 
    31 
    32 
    32 const TUint8 KDayOfWeekSeparator    = ',';
    33 const TUint8 KDayOfWeekSeparator    = ',';
    33 // const TUint8 KTimeSeparator         = ':';
    34 // const TUint8 KTimeSeparator         = ':';
    53 _LIT8( KLocalSeparators, " -");
    54 _LIT8( KLocalSeparators, " -");
    54 _LIT8( KLocalTimeSeparator, ":");
    55 _LIT8( KLocalTimeSeparator, ":");
    55 
    56 
    56 _LIT8( KLocalMonthNames, "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec" );
    57 _LIT8( KLocalMonthNames, "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec" );
    57 
    58 
    58 
    59 #ifdef __TEST_COOKIE_LOG__
       
    60 static void LogCookieAttribute( const CCookie& aCookie, const RStringPool& aPool, TInt aId, const TDesC8& aTextName, CCookie::TCookieAttributeName aAttributeName )
       
    61     {
       
    62     _LIT(KDateFormat,"%D%M%Y%/0%1%/1%2%/2%3%/3 %:0%H%:1%T%:2%S.%C%:3");
       
    63     THTTPHdrVal fieldVal;
       
    64 
       
    65     const TInt attribErr = aCookie.Attribute( aAttributeName, fieldVal );
       
    66     if ( attribErr == KErrNone )
       
    67         {
       
    68         switch ( fieldVal.Type() )
       
    69             {
       
    70         case THTTPHdrVal::KTIntVal:
       
    71             CLOG( ( ECookie, 0, _L8( "{%3d}  [Int]  %S = (%d)"), aId, &aTextName, fieldVal.Int() ) );
       
    72             break;
       
    73 
       
    74         case THTTPHdrVal::KStrFVal:
       
    75             {
       
    76             RStringF fieldValStr = aPool.StringF( fieldVal.StrF() );
       
    77             const TDesC8& fieldValDesC = fieldValStr.DesC();
       
    78             CLOG( ( ECookie, 0, _L8( "{%3d}  [StrF] %S = (%S)"), aId, &aTextName, &fieldValDesC ) );
       
    79             }
       
    80             break;
       
    81 
       
    82         case THTTPHdrVal::KStrVal:
       
    83             {
       
    84             RString fieldValStr = aPool.String( fieldVal.Str() );
       
    85             const TDesC8& fieldValDesC = fieldValStr.DesC();
       
    86             CLOG( ( ECookie, 0, _L8( "{%3d}  [Str]  %S = (%S)"), aId, &aTextName, &fieldValDesC ) );
       
    87             }
       
    88             break;
       
    89 
       
    90         case THTTPHdrVal::KDateVal:
       
    91             {
       
    92             TDateTime date = fieldVal.DateTime();
       
    93             TBuf<40> dateTimeString;
       
    94             TTime t( date );
       
    95             TRAP_IGNORE( t.FormatL( dateTimeString, KDateFormat ) );
       
    96             TBuf8<40> dateTimeString8;
       
    97             dateTimeString8.Copy( dateTimeString );
       
    98             CLOG( ( ECookie, 0, _L8( "{%3d}  [Date] %S = (%S)"), aId, &aTextName, &dateTimeString8 ) );
       
    99             } 
       
   100             break;
       
   101 
       
   102         default:
       
   103             CLOG(( ECookie, 0, _L8("{%3d}  [????] %S = (%d)"), aId, &aTextName, fieldVal.Type() ));
       
   104             break;
       
   105             }
       
   106         }
       
   107     else
       
   108         {
       
   109         //CLOG( ( ECookie, 0, _L8( "{%3d}  LogCookie - absent: %S"), aId, &aTextName ) );
       
   110         }
       
   111     }
       
   112 #endif
       
   113 
       
   114 // ---------------------------------------------------------
       
   115 // CCookie::Log
       
   116 // ---------------------------------------------------------
       
   117 //
       
   118 void CCookie::Log( TInt aAssociatedId ) const
       
   119     {
       
   120 	TInt associateId = aAssociatedId;
       
   121 	CLOG( ( ECookie, 0, _L( "-> CCookie::Log() - Associate Id:%d"), associateId ) );
       
   122 #ifdef __TEST_COOKIE_LOG__
       
   123     const TInt count = iAttributes.Count();
       
   124     CLOG( ( ECookie, 0, _L( "-> CCookie::Log() - %d attributes..."), count ) );
       
   125     for( TInt i=0; i<count; i++ )
       
   126         {
       
   127         // Calculating/fetching size is enough to generate usable logs
       
   128         const TCookieAttribute& attrib = iAttributes[ i ];
       
   129         const TInt size = attrib.Size();
       
   130         }
       
   131 
       
   132     LogCookieAttribute( *this, iStringPool, aAssociatedId, _L8("Name"), CCookie::EName );
       
   133     LogCookieAttribute( *this, iStringPool, aAssociatedId, _L8("Value"), CCookie::EValue );
       
   134     LogCookieAttribute( *this, iStringPool, aAssociatedId, _L8("Domain"), CCookie::EDomain );
       
   135     LogCookieAttribute( *this, iStringPool, aAssociatedId, _L8("Path"), CCookie::EPath );
       
   136     LogCookieAttribute( *this, iStringPool, aAssociatedId, _L8("Date"), CCookie::EDate );
       
   137     LogCookieAttribute( *this, iStringPool, aAssociatedId, _L8("Version"), CCookie::EVersion );
       
   138     LogCookieAttribute( *this, iStringPool, aAssociatedId, _L8("Expires"), CCookie::EExpires );
       
   139     LogCookieAttribute( *this, iStringPool, aAssociatedId, _L8("MaxAge"), CCookie::EMaxAge );
       
   140     LogCookieAttribute( *this, iStringPool, aAssociatedId, _L8("Discard"), CCookie::EDiscard );
       
   141     LogCookieAttribute( *this, iStringPool, aAssociatedId, _L8("Port"), CCookie::EPort );
       
   142     LogCookieAttribute( *this, iStringPool, aAssociatedId, _L8("Secure"), CCookie::ESecure );
       
   143     LogCookieAttribute( *this, iStringPool, aAssociatedId, _L8("Comment"), CCookie::EComment );
       
   144     LogCookieAttribute( *this, iStringPool, aAssociatedId, _L8("Comment URI"), CCookie::ECommentURI );
       
   145     CLOG( ( ECookie, 0, _L( "{%3d}         fromCookie2: %d, fromNetscapeVersion: %d"), aAssociatedId, FromCookie2(), FromNetscapeVersion() ) );
       
   146     CLOG( ( ECookie, 0, _L( "{%3d}         expired: %d, persists: %d, unknownVer: %d"), aAssociatedId, Expired(), Persistent(), IsUnknownVersion() ) );
       
   147     CLOG( ( ECookie, 0, _L( "<- CCookie::Log() - %d attributes..."), count ) );
       
   148 #endif
       
   149     }
    59 
   150 
    60 
   151 
    61 // ---------------------------------------------------------
   152 // ---------------------------------------------------------
    62 // CCookie::NewL
   153 // CCookie::NewL
    63 // ---------------------------------------------------------
   154 // ---------------------------------------------------------
    84 //
   175 //
    85 EXPORT_C CCookie* CCookie::NewL( RStringPool aStringPool )
   176 EXPORT_C CCookie* CCookie::NewL( RStringPool aStringPool )
    86 	{
   177 	{
    87 	return new (ELeave) CCookie( aStringPool );
   178 	return new (ELeave) CCookie( aStringPool );
    88 	}
   179 	}
       
   180 // ---------------------------------------------------------
       
   181 // CCookie::NewL
       
   182 // ---------------------------------------------------------
       
   183 //
       
   184 CCookie* CCookie::CloneL( const CCookie& aCopy )
       
   185     {
       
   186     CCookie* self = new(ELeave) CCookie( aCopy.iStringPool );
       
   187     CleanupStack::PushL( self );
       
   188     self->CopyFromL( aCopy );
       
   189     CleanupStack::Pop( self );
       
   190     return self;
       
   191     }
    89 	
   192 	
    90 
   193 
    91 // ---------------------------------------------------------
   194 // ---------------------------------------------------------
    92 // CCookie::~CCookie
   195 // CCookie::~CCookie
    93 // ---------------------------------------------------------
   196 // ---------------------------------------------------------
    94 //
   197 //
    95 EXPORT_C CCookie::~CCookie()
   198 EXPORT_C CCookie::~CCookie()
    96 	{
   199 	{
    97 	// go through each attribute closing any attribute strings	
   200 	// go through each attribute closing any attribute strings	
    98 	TInt numAttributes = iAttributes.Count();
   201 	TInt numAttributes = iAttributes.Count();
       
   202 	Log();
       
   203 	CLOG( ( ECookie, 0, _L( "-> CCookie::~CCookie - this: 0x%08x, numAttributes: %d"), this, numAttributes ) );
    99 	for ( TInt ii = 0; ii < numAttributes; ++ii )
   204 	for ( TInt ii = 0; ii < numAttributes; ++ii )
   100 		{
   205 		{
   101 		iAttributes[ii].Close();
   206 		iAttributes[ii].Close();
   102 		}
   207 		}
   103 
   208 
   104 	iAttributes.Close();
   209 	iAttributes.Close();
       
   210 	CLOG( ( ECookie, 0, _L( "<- CCookie::~CCookie - this: 0x%08x, count: %d"), this, numAttributes ) );
   105 	}
   211 	}
   106 
   212 
   107 
   213 
   108 // ---------------------------------------------------------
   214 // ---------------------------------------------------------
   109 // CCookie::AddDefaultPathL
   215 // CCookie::AddDefaultPathL
   110 // ---------------------------------------------------------
   216 // ---------------------------------------------------------
   111 //
   217 //
   112 void CCookie::AddDefaultPathL( const TUriC8& aUri )
   218 void CCookie::AddDefaultPathL( const TUriC8& aUri )
   113 	{
   219 	{
       
   220 	CLOG( ( ECookie, 0, _L( "-> CCookie::AddDefaultPathL") ) );
   114 	// RFC2965 : Defaults to the path of the request URL that generated the
   221 	// RFC2965 : Defaults to the path of the request URL that generated the
   115 	// Set-Cookie2 response, up to and including the right-most /.
   222 	// Set-Cookie2 response, up to and including the right-most /.
   116 	// Note : there is a contradiction as we must not include the right-most /
   223 	// Note : there is a contradiction as we must not include the right-most /
   117 	// per RFC2109, which is obsolete. Decision : we support RFC2965.
   224 	// per RFC2109, which is obsolete. Decision : we support RFC2965.
   118 	const TUint8 KCookiePathSeparator = '/';
   225 	const TUint8 KCookiePathSeparator = '/';
   137 
   244 
   138     RStringF defPath = iStringPool.OpenFStringL( requestPath );
   245     RStringF defPath = iStringPool.OpenFStringL( requestPath );
   139     THTTPHdrVal defPathVal( defPath );
   246     THTTPHdrVal defPathVal( defPath );
   140 	SetAttribute( EPath, defPathVal, ETrue );// ignore the result 
   247 	SetAttribute( EPath, defPathVal, ETrue );// ignore the result 
   141     defPath.Close();
   248     defPath.Close();
       
   249     CLOG( ( ECookie, 0, _L( "<- CCookie::AddDefaultPathL") ) );
   142 	}
   250 	}
   143 
   251 
   144 // ---------------------------------------------------------
   252 // ---------------------------------------------------------
   145 // CCookie::AddToRequestL
   253 // CCookie::AddToRequestL
   146 // ---------------------------------------------------------
   254 // ---------------------------------------------------------
   147 //
   255 //
   148 EXPORT_C void CCookie::AddToRequestL( RHTTPHeaders aRequestHeaders,
   256 EXPORT_C void CCookie::AddToRequestL( RHTTPHeaders aRequestHeaders,
   149 									 TInt aPartIndex ) const
   257 									 TInt aPartIndex ) const
   150 	{
   258 	{
       
   259 	CLOG( ( ECookie, 0, _L( "-> CCookie::AddToRequestL") ) );
   151 	const TStringTable& commonStringTable = RHTTPSession::GetTable();
   260 	const TStringTable& commonStringTable = RHTTPSession::GetTable();
   152 
   261 
   153 	// We're writing out the "Cookie:" string
   262 	// We're writing out the "Cookie:" string
   154 	RStringF cookieString =
   263 	RStringF cookieString =
   155 					iStringPool.StringF( HTTP::ECookie, commonStringTable );
   264 					iStringPool.StringF( HTTP::ECookie, commonStringTable );
   167 							hVal,
   276 							hVal,
   168 							aPartIndex );
   277 							aPartIndex );
   169 		}
   278 		}
   170 	else
   279 	else
   171 		{
   280 		{
       
   281 		CLOG( ( ECookie, 0, _L( "CCookie::AddToRequestL - version is missing! - iSetCookie2: %d"), iSetCookie2 ) );
   172 		if ( iSetCookie2 )
   282 		if ( iSetCookie2 )
   173 			{
   283 			{
   174 			// if this is a new-style cookie (it is from a Set-Cookie2 header),
   284 			// if this is a new-style cookie (it is from a Set-Cookie2 header),
   175 			// then it must have a Version attribute.
   285 			// then it must have a Version attribute.
   176 			// TBD : or should we insert a '$Version=1' string instead?
   286 			// TBD : or should we insert a '$Version=1' string instead?
       
   287 			CLOG( ( ECookie, 0, _L( "<- CCookie::AddToRequestL - KErrCorrupt!") ) );
   177 			User::Leave( KErrCorrupt );
   288 			User::Leave( KErrCorrupt );
   178 			}
   289 			}
   179 		}
   290 		}
   180 
   291 	CLOG( ( ECookie, 0, _L( "CCookie::AddToRequestL - adding name...") ) );
   181 	// We're writing out the NAME attribute - it is a serious error if this
   292 	// We're writing out the NAME attribute - it is a serious error if this
   182 	// attribute is missing
   293 	// attribute is missing
   183 	User::LeaveIfError( Attribute( CCookie::EName, hVal ) );
   294 	User::LeaveIfError( Attribute( CCookie::EName, hVal ) );
   184 	aRequestHeaders.SetParamL( cookieString,
   295 	aRequestHeaders.SetParamL( cookieString,
   185 							iStringPool.StringF( HTTP::ECookieName,
   296 							iStringPool.StringF( HTTP::ECookieName,
   186 												commonStringTable ), 
   297 												commonStringTable ), 
   187 							hVal,
   298 							hVal,
   188 							aPartIndex );
   299 							aPartIndex );
   189 
   300 
       
   301 	CLOG( ( ECookie, 0, _L( "CCookie::AddToRequestL - adding value...") ) );
   190 	// We're writing out the VALUE attribute - it is a serious error if this
   302 	// We're writing out the VALUE attribute - it is a serious error if this
   191 	// attribute is missing
   303 	// attribute is missing
   192 	User::LeaveIfError( Attribute( CCookie::EValue, hVal ) );
   304 	User::LeaveIfError( Attribute( CCookie::EValue, hVal ) );
   193 	aRequestHeaders.SetParamL( cookieString,
   305 	aRequestHeaders.SetParamL( cookieString,
   194 							iStringPool.StringF( HTTP::ECookieValue,
   306 							iStringPool.StringF( HTTP::ECookieValue,
   199 	// Writing out the rest : domain, path and port. These are not mandatory,
   311 	// Writing out the rest : domain, path and port. These are not mandatory,
   200 	// thus we do not leave if they are missing.
   312 	// thus we do not leave if they are missing.
   201 	// Writing out Domain attribute
   313 	// Writing out Domain attribute
   202 	if ( Attribute( CCookie::EDomain, hVal ) == KErrNone && hVal.StrF().DesC().Length() > 0 )
   314 	if ( Attribute( CCookie::EDomain, hVal ) == KErrNone && hVal.StrF().DesC().Length() > 0 )
   203         {
   315         {
       
   316         CLOG( ( ECookie, 0, _L( "CCookie::AddToRequestL - adding domain...") ) );
   204 		aRequestHeaders.SetParamL( cookieString,
   317 		aRequestHeaders.SetParamL( cookieString,
   205 								iStringPool.StringF( HTTP::EDomain,
   318 								iStringPool.StringF( HTTP::EDomain,
   206 													commonStringTable ),
   319 													commonStringTable ),
   207 								hVal,
   320 								hVal,
   208 								aPartIndex );
   321 								aPartIndex );
   209         }
   322         }
   210 
   323 
   211 	// Writing out Path attribute
   324 	// Writing out Path attribute
   212 	if ( Attribute( CCookie::EPath, hVal ) == KErrNone )
   325 	if ( Attribute( CCookie::EPath, hVal ) == KErrNone )
   213         {
   326         {
       
   327         CLOG( ( ECookie, 0, _L( "CCookie::AddToRequestL - adding path...") ) );
   214 		aRequestHeaders.SetParamL( cookieString,
   328 		aRequestHeaders.SetParamL( cookieString,
   215 								iStringPool.StringF( HTTP::EPath,
   329 								iStringPool.StringF( HTTP::EPath,
   216 													commonStringTable ),
   330 													commonStringTable ),
   217 								hVal,
   331 								hVal,
   218 								aPartIndex );
   332 								aPartIndex );
   219         }
   333         }
   220 
   334 
   221 	// Writing out Port attribute
   335 	// Writing out Port attribute
   222 	if ( Attribute( CCookie::EPort, hVal ) == KErrNone )
   336 	if ( Attribute( CCookie::EPort, hVal ) == KErrNone )
   223         {
   337         {
       
   338         CLOG( ( ECookie, 0, _L( "CCookie::AddToRequestL - adding port...") ) );
   224 		aRequestHeaders.SetParamL( cookieString,
   339 		aRequestHeaders.SetParamL( cookieString,
   225 								iStringPool.StringF( HTTP::ECookiePort,
   340 								iStringPool.StringF( HTTP::ECookiePort,
   226 													commonStringTable ),
   341 													commonStringTable ),
   227 								hVal,
   342 								hVal,
   228 								aPartIndex );
   343 								aPartIndex );
   229         }
   344         }
       
   345 	CLOG( ( ECookie, 0, _L( "<- CCookie::AddToRequestL") ) );
   230 	}
   346 	}
   231 
   347 
   232 
   348 
   233 // ---------------------------------------------------------
   349 // ---------------------------------------------------------
   234 // CCookie::Attribute
   350 // CCookie::Attribute
   236 //
   352 //
   237 EXPORT_C TInt CCookie::Attribute
   353 EXPORT_C TInt CCookie::Attribute
   238 							( CCookie::TCookieAttributeName aAttributeName,
   354 							( CCookie::TCookieAttributeName aAttributeName,
   239 								THTTPHdrVal& aAttributeVal) const
   355 								THTTPHdrVal& aAttributeVal) const
   240 	{
   356 	{
       
   357 	CLOG( ( ECookie, 0, _L( "-> CCookie::Attribute") ) );
   241 	TCookieAttribute attribute;
   358 	TCookieAttribute attribute;
   242 	if ( FindAttribute( aAttributeName, attribute ) != KErrNotFound )
   359 	if ( FindAttribute( aAttributeName, attribute ) != KErrNotFound )
   243 		{
   360 		{
   244 		aAttributeVal = attribute.Value();
   361 		aAttributeVal = attribute.Value();
       
   362 		CLOG( ( ECookie, 0, _L( "<- CCookie::Attribute") ) );
   245 		return KErrNone;
   363 		return KErrNone;
   246 		}
   364 		}
   247 
   365 	CLOG( ( ECookie, 0, _L( "<- CCookie::Attribute") ) );
   248 	return KErrNotFound;
   366 	return KErrNotFound;
   249 	}
   367 	}
   250 
   368 
   251 
   369 
   252 // ---------------------------------------------------------
   370 // ---------------------------------------------------------
   268 //
   386 //
   269 TInt CCookie::Attribute( TCookieAttributeName aAttributeName,
   387 TInt CCookie::Attribute( TCookieAttributeName aAttributeName,
   270 						 THTTPHdrVal& aAttributeVal,
   388 						 THTTPHdrVal& aAttributeVal,
   271 						 TBool& aDefaulted ) const
   389 						 TBool& aDefaulted ) const
   272 	{
   390 	{
       
   391 	CLOG( ( ECookie, 0, _L( "-> CCookie::Attribute ") ) );
   273 	TCookieAttribute attribute;
   392 	TCookieAttribute attribute;
   274 	if ( FindAttribute( aAttributeName, attribute ) != KErrNotFound )
   393 	if ( FindAttribute( aAttributeName, attribute ) != KErrNotFound )
   275 		{
   394 		{
   276 		aAttributeVal = attribute.Value();
   395 		aAttributeVal = attribute.Value();
   277 		aDefaulted = attribute.Defaulted();
   396 		aDefaulted = attribute.Defaulted();
       
   397 		CLOG( ( ECookie, 0, _L( "<- CCookie::Attribute KErrNone") ) );
   278 		return KErrNone;
   398 		return KErrNone;
   279 		}
   399 		}
   280 
   400 	CLOG( ( ECookie, 0, _L( "<- CCookie::Attribute KErrNotFound") ) );
   281 	return KErrNotFound;
   401 	return KErrNotFound;
   282 	}
   402 	}
   283 
   403 
   284 
   404 
   285 // ---------------------------------------------------------
   405 // ---------------------------------------------------------
   288 //
   408 //
   289 TInt CCookie::SetAttribute(  TCookieAttributeName aAttributeName,
   409 TInt CCookie::SetAttribute(  TCookieAttributeName aAttributeName,
   290 							const THTTPHdrVal& aAttributeVal,
   410 							const THTTPHdrVal& aAttributeVal,
   291 							TBool aDefaulted )
   411 							TBool aDefaulted )
   292 {
   412 {
       
   413     CLOG( ( ECookie, 0, _L( "-> CCookie::SetAttribute") ) );
   293 	TInt result( KErrNone );
   414 	TInt result( KErrNone );
   294 
   415 
   295 	TCookieAttribute attribute;
   416 	TCookieAttribute attribute;
   296 	TInt index = FindAttribute( aAttributeName, attribute );
   417 	TInt index = FindAttribute( aAttributeName, attribute );
   297 	if ( index != KErrNotFound )
   418 	if ( index != KErrNotFound )
   313 		else
   434 		else
   314 			{
   435 			{
   315 			newAttribute.Close();
   436 			newAttribute.Close();
   316 			}
   437 			}
   317 		}
   438 		}
       
   439 	CLOG( ( ECookie, 0, _L( "<- CCookie::SetAttribute result: %d"),result ) );
   318 	return result;
   440 	return result;
   319 }
   441 }
   320 
   442 
   321 // ---------------------------------------------------------
   443 // ---------------------------------------------------------
   322 // CCookie::CopyFromL
   444 // CCookie::CopyFromL
   323 // ---------------------------------------------------------
   445 // ---------------------------------------------------------
   324 //
   446 //
   325 void CCookie::CopyFromL( const CCookie& aCopyFrom  )
   447 void CCookie::CopyFromL( const CCookie& aCopyFrom  )
   326     {
   448     {
   327 	THTTPHdrVal attributevalue;
   449     CLOG( ( ECookie, 0, _L( "-> CCookie::CopyFromL ") ) );
   328     TBool aDefaulted( EFalse );
   450     THTTPHdrVal attributevalue;
   329 
   451     TBool defaulted( EFalse );
   330     if ( aCopyFrom.Attribute( EName, attributevalue, aDefaulted ) != KErrNotFound )
   452     if ( aCopyFrom.Attribute( EName, attributevalue, defaulted ) != KErrNotFound )
   331         {
   453         {
   332         SetAttribute( EName, attributevalue, aDefaulted );
   454         if ( attributevalue.Type() != THTTPHdrVal::KStrVal )
   333         }
   455              {
   334 
   456              RString correctedStringType = iStringPool.OpenStringL( attributevalue.StrF().DesC() );
   335 	if ( aCopyFrom.Attribute( EValue, attributevalue, aDefaulted ) != KErrNotFound )
   457              attributevalue.SetStr( correctedStringType );
   336         {
   458              SetAttribute( EName, attributevalue, defaulted );
   337         SetAttribute( EValue, attributevalue, aDefaulted );
   459              correctedStringType.Close();
   338         }
   460              const TPtrC8 pVal( attributevalue.Str().DesC() );
   339 
   461              CLOG( ( ECookie, 0, _L8( "CCookie::CopyFromL - attribute EName Value : %S" ), &pVal ) );
   340 	if ( aCopyFrom.Attribute( EComment, attributevalue, aDefaulted ) != KErrNotFound )
   462              }
   341         {
   463         else 
   342         SetAttribute( EComment, attributevalue, aDefaulted );
   464             {
   343         }
   465             SetAttribute( EName, attributevalue, defaulted );    
   344 
   466             }
   345 	if ( aCopyFrom.Attribute( ECommentURI, attributevalue, aDefaulted ) != KErrNotFound )
   467         }
   346         {
   468 
   347         SetAttribute( ECommentURI, attributevalue, aDefaulted );
   469     if ( aCopyFrom.Attribute( EValue, attributevalue, defaulted ) != KErrNotFound )
   348         }
   470         {
   349 
   471          if ( attributevalue.Type() != THTTPHdrVal::KStrVal )
   350 	if ( aCopyFrom.Attribute( EDiscard, attributevalue, aDefaulted ) != KErrNotFound )
   472             {
   351         {
   473             RString correctedStringType = iStringPool.OpenStringL( attributevalue.StrF().DesC() );
   352         SetAttribute( EDiscard, attributevalue, aDefaulted );
   474             attributevalue.SetStr( correctedStringType );
   353         }
   475             SetAttribute( EValue, attributevalue, defaulted );
   354 
   476             correctedStringType.Close();
   355 	if ( aCopyFrom.Attribute( EDomain, attributevalue, aDefaulted ) != KErrNotFound )
   477             const TPtrC8 pVal( attributevalue.Str().DesC() );
   356         {
   478             CLOG( ( ECookie, 0, _L8( "CCookie::CopyFromL - attribute EValue value: %S" ), &pVal ) );
   357         SetAttribute( EDomain, attributevalue, aDefaulted );
   479             }
   358         }
   480          else
   359 
   481              {
   360 	if ( aCopyFrom.Attribute( EMaxAge, attributevalue, aDefaulted ) != KErrNotFound )
   482              SetAttribute( EValue, attributevalue, defaulted );             
   361         {
   483              }
   362         SetAttribute( EMaxAge, attributevalue, aDefaulted );
   484         }
   363         }
   485 	if ( aCopyFrom.Attribute( EComment, attributevalue, defaulted ) != KErrNotFound )
   364 
   486         {
   365 	if ( aCopyFrom.Attribute( EPath, attributevalue, aDefaulted ) != KErrNotFound )
   487         SetAttribute( EComment, attributevalue, defaulted );
   366         {
   488         }
   367         SetAttribute( EPath, attributevalue, aDefaulted );
   489 
   368         }
   490 	if ( aCopyFrom.Attribute( ECommentURI, attributevalue, defaulted ) != KErrNotFound )
   369 
   491         {
   370 	if ( aCopyFrom.Attribute( EPort, attributevalue, aDefaulted ) != KErrNotFound )
   492         SetAttribute( ECommentURI, attributevalue, defaulted );
   371         {
   493         }
   372         SetAttribute( EPort, attributevalue, aDefaulted );
   494 
   373         }
   495 	if ( aCopyFrom.Attribute( EDiscard, attributevalue, defaulted ) != KErrNotFound )
   374 
   496         {
   375 	if ( aCopyFrom.Attribute( ESecure, attributevalue, aDefaulted ) != KErrNotFound )
   497         SetAttribute( EDiscard, attributevalue, defaulted );
   376         {
   498         }
   377         SetAttribute( ESecure, attributevalue, aDefaulted );
   499 
   378         }
   500 	if ( aCopyFrom.Attribute( EDomain, attributevalue, defaulted ) != KErrNotFound )
   379 
   501         {
   380 	if ( aCopyFrom.Attribute( EVersion, attributevalue, aDefaulted ) != KErrNotFound )
   502         SetAttribute( EDomain, attributevalue, defaulted );
   381         {
   503         }
   382         SetAttribute( EVersion, attributevalue, aDefaulted );
   504 
   383         }
   505 	if ( aCopyFrom.Attribute( EMaxAge, attributevalue, defaulted ) != KErrNotFound )
   384 
   506         {
   385 	if ( aCopyFrom.Attribute( EExpires, attributevalue, aDefaulted ) != KErrNotFound )
   507         SetAttribute( EMaxAge, attributevalue, defaulted );
   386         {
   508         }
   387         SetAttribute( EExpires, attributevalue, aDefaulted );
   509 
   388         }
   510 	if ( aCopyFrom.Attribute( EPath, attributevalue, defaulted ) != KErrNotFound )
   389 
   511         {
   390     SetCookie2( aCopyFrom.FromCookie2() );
   512         SetAttribute( EPath, attributevalue, defaulted );
   391 
   513         }
       
   514 
       
   515 	if ( aCopyFrom.Attribute( EPort, attributevalue, defaulted ) != KErrNotFound )
       
   516         {
       
   517         SetAttribute( EPort, attributevalue, defaulted );
       
   518         }
       
   519 
       
   520 	if ( aCopyFrom.Attribute( ESecure, attributevalue, defaulted ) != KErrNotFound )
       
   521         {
       
   522         SetAttribute( ESecure, attributevalue, defaulted );
       
   523         }
       
   524 
       
   525 	if ( aCopyFrom.Attribute( EVersion, attributevalue, defaulted ) != KErrNotFound )
       
   526         {
       
   527         SetAttribute( EVersion, attributevalue, defaulted );
       
   528         }
       
   529 
       
   530 	if ( aCopyFrom.Attribute( EExpires, attributevalue, defaulted ) != KErrNotFound )
       
   531         {
       
   532         SetAttribute( EExpires, attributevalue, defaulted );
       
   533         }
       
   534 
       
   535     //SetCookie2( aCopyFrom.FromCookie2() );
       
   536     // Other properties
       
   537     iSetCookie2 = aCopyFrom.iSetCookie2;
       
   538     iNetscape = aCopyFrom.iNetscape;
       
   539     iSize = aCopyFrom.iSize;
       
   540     iReceivedTime = aCopyFrom.iReceivedTime;
       
   541     CLOG( ( ECookie, 0, _L( "<- CCookie::CopyFromL ") ) );
   392     }
   542     }
   393 
   543 
   394 
   544 
   395 
   545 
   396 
   546 
   409 // CCookie::Expired
   559 // CCookie::Expired
   410 // ---------------------------------------------------------
   560 // ---------------------------------------------------------
   411 //
   561 //
   412 TBool CCookie::Expired() const
   562 TBool CCookie::Expired() const
   413 	{
   563 	{
       
   564 	CLOG( ( ECookie, 0, _L( "-> CCookie::Expired ") ) );
   414     // the cookie has expired if:
   565     // the cookie has expired if:
   415     // 1. it's Age > Max-Age
   566     // 1. it's Age > Max-Age
   416     // 2. current_date > expires
   567     // 2. current_date > expires
   417     // Expires is in Netscape cookie only !!!
   568     // Expires is in Netscape cookie only !!!
   418 
   569 
   477                         
   628                         
   478                     
   629                     
   479                 }
   630                 }
   480 			}
   631 			}
   481 		}
   632 		}
       
   633 	CLOG( ( ECookie, 0, _L( "<- CCookie::Expired retval : %d"),retval ) );
   482 	return retval;
   634 	return retval;
   483 	}
   635 	}
   484 // ---------------------------------------------------------
   636 // ---------------------------------------------------------
   485 // CCookie::RemoveQuotes
   637 // CCookie::RemoveQuotes
   486 // ---------------------------------------------------------
   638 // ---------------------------------------------------------
   487 //
   639 //
   488  TPtrC8 CCookie::RemoveQuotes( const TDesC8& aDes ) 
   640  TPtrC8 CCookie::RemoveQuotes( const TDesC8& aDes ) 
   489 	{
   641 	{
   490    
   642 	CLOG( ( ECookie, 0, _L( "-> CCookie::RemoveQuotes ") ) );
   491 	TInt firstChar = 0;					// position of the first character
   643 	TInt firstChar = 0;					// position of the first character
   492 	TInt lastChar = aDes.Length() - 1;	// position of the last character
   644 	TInt lastChar = aDes.Length() - 1;	// position of the last character
   493 	TPtrC8 result;
   645 	TPtrC8 result;
   494 	if ( lastChar < 0 )	// that is, aDes has a length of zero
   646 	if ( lastChar < 0 )	// that is, aDes has a length of zero
   495 		{
   647 		{
   516 		else
   668 		else
   517 			{
   669 			{
   518 			result.Set( aDes.Mid( firstChar, lastChar - firstChar + 1 ) );
   670 			result.Set( aDes.Mid( firstChar, lastChar - firstChar + 1 ) );
   519 			}
   671 			}
   520 		}
   672 		}
   521 
   673 	CLOG( ( ECookie, 0, _L( "<- CCookie::RemoveQuotes result : %d "),result ) );
   522     return result;
   674     return result;
   523 	}
   675 	}
   524 
   676 
   525 
   677 
   526 
   678 
   528 // CCookie::ExpiredNetscapeL
   680 // CCookie::ExpiredNetscapeL
   529 // ---------------------------------------------------------
   681 // ---------------------------------------------------------
   530 //
   682 //
   531 TBool CCookie::ExpiredNetscapeL( THTTPHdrVal aAttrVal) const
   683 TBool CCookie::ExpiredNetscapeL( THTTPHdrVal aAttrVal) const
   532     {
   684     {
       
   685     CLOG( ( ECookie, 0, _L( "-> CCookie::ExpiredNetscapeL ") ) );
   533     TBool retval( EFalse );
   686     TBool retval( EFalse );
   534     TPtrC8 datePtr8( aAttrVal.StrF().DesC() );
   687     TPtrC8 datePtr8( aAttrVal.StrF().DesC() );
   535     TInt dateLen( datePtr8.Length() );
   688     TInt dateLen( datePtr8.Length() );
   536     if( dateLen == 0 )
   689     if( dateLen == 0 )
   537         {
   690         {
   734     else  // invalid Date is expired!
   887     else  // invalid Date is expired!
   735         {
   888         {
   736         retval = ETrue;
   889         retval = ETrue;
   737         }
   890         }
   738     CleanupStack::PopAndDestroy( cleanupNum ); // temp1, temp2, desDate, desTime
   891     CleanupStack::PopAndDestroy( cleanupNum ); // temp1, temp2, desDate, desTime
       
   892     CLOG( ( ECookie, 0, _L( "<- CCookie::ExpiredNetscapeL retval : %d "),retval ) );
   739     return retval;
   893     return retval;
   740     }
   894     }
   741 
   895 
   742 
   896 
   743 // ---------------------------------------------------------
   897 // ---------------------------------------------------------
   747 TInt CCookie::FindTokens( const TDesC8& aString, 
   901 TInt CCookie::FindTokens( const TDesC8& aString, 
   748                          const TDesC8& aTokenSeparators, 
   902                          const TDesC8& aTokenSeparators, 
   749                          const TInt aTokenCount, 
   903                          const TInt aTokenCount, 
   750                          TInt* aTokens ) const
   904                          TInt* aTokens ) const
   751     {
   905     {
       
   906     CLOG( ( ECookie, 0, _L( "-> CCookie::FindTokens ") ) );
   752     TLex8 lex = aString;
   907     TLex8 lex = aString;
   753     TChar ch;
   908     TChar ch;
   754     TInt tokenCount( 0 ), ii;
   909     TInt tokenCount( 0 ), ii;
   755     for(ii=0; ii<aTokenCount; aTokens[ii++] = KErrNotFound) ;
   910     for(ii=0; ii<aTokenCount; aTokens[ii++] = KErrNotFound) ;
   756 
   911 
   760         if( aTokenSeparators.Locate( ch ) != KErrNotFound ) 
   915         if( aTokenSeparators.Locate( ch ) != KErrNotFound ) 
   761             {
   916             {
   762             aTokens[tokenCount++] = lex.Offset()-1;
   917             aTokens[tokenCount++] = lex.Offset()-1;
   763             }
   918             }
   764         }
   919         }
       
   920     CLOG( ( ECookie, 0, _L( "<- CCookie::FindTokens tokenCount : %d"),tokenCount ) );
   765     return tokenCount;
   921     return tokenCount;
   766     }
   922     }
   767 
   923 
   768 // ---------------------------------------------------------
   924 // ---------------------------------------------------------
   769 // CCookie::Persistent
   925 // CCookie::Persistent
   770 // ---------------------------------------------------------
   926 // ---------------------------------------------------------
   771 //
   927 //
   772 TBool CCookie::Persistent() const
   928 TBool CCookie::Persistent() const
   773     {
   929     {
       
   930     CLOG( ( ECookie, 0, _L( "-> CCookie::Persistent ") ) );
   774     TBool result( EFalse );
   931     TBool result( EFalse );
   775 	THTTPHdrVal attrVal;
   932 	THTTPHdrVal attrVal;
   776 
   933 
   777     if ( FromNetscapeVersion() )
   934     if ( FromNetscapeVersion() )
   778         {
   935         {
   816                     result = ETrue;
   973                     result = ETrue;
   817                     }
   974                     }
   818                 }
   975                 }
   819             }
   976             }
   820         }
   977         }
       
   978     CLOG( ( ECookie, 0, _L( "<- CCookie::Persistent result : %d"),result ) );
   821     return result;
   979     return result;
   822     }
   980     }
   823 
   981 
   824 // ---------------------------------------------------------
   982 // ---------------------------------------------------------
   825 // CCookie::IsUnknownVersion
   983 // CCookie::IsUnknownVersion
   826 // ---------------------------------------------------------
   984 // ---------------------------------------------------------
   827 //
   985 //
   828 TBool CCookie::IsUnknownVersion() const
   986 TBool CCookie::IsUnknownVersion() const
   829     {
   987     {
       
   988     CLOG( ( ECookie, 0, _L( "-> CCookie::IsUnknownVersion ") ) );
   830     TBool unknownVersion( EFalse );
   989     TBool unknownVersion( EFalse );
   831     THTTPHdrVal attrVal;
   990     THTTPHdrVal attrVal;
   832     if( Attribute( CCookie::EVersion, attrVal ) != KErrNotFound )
   991     if( Attribute( CCookie::EVersion, attrVal ) != KErrNotFound )
   833         {
   992         {
   834         if( attrVal.StrF().DesC().Compare( KCookieKnownVersion() ) != 0 )
   993         if( attrVal.StrF().DesC().Compare( KCookieKnownVersion() ) != 0 )
   835             {
   994             {
   836             unknownVersion = ETrue;
   995             unknownVersion = ETrue;
   837             }
   996             }
   838         }
   997         }
       
   998     CLOG( ( ECookie, 0, _L( "<- CCookie::IsUnknownVersion unknownVersion : %d"),unknownVersion ) );
   839     return unknownVersion;
   999     return unknownVersion;
   840     }
  1000     }
   841 
  1001 
   842 // ---------------------------------------------------------
  1002 // ---------------------------------------------------------
   843 // CCookie::CCookie
  1003 // CCookie::CCookie
   844 // ---------------------------------------------------------
  1004 // ---------------------------------------------------------
   845 //
  1005 //
   846 CCookie::CCookie( RStringPool aStringPool )
  1006 CCookie::CCookie( RStringPool aStringPool )
   847 : iStringPool( aStringPool ), iSetCookie2( EFalse ), iNetscape( EFalse )
  1007 : iStringPool( aStringPool ), iSetCookie2( EFalse ), iNetscape( EFalse )
   848 	{
  1008 	{
       
  1009 	CLOG( ( ECookie, 0, _L( "-> CCookie::CCookie ") ) );
   849 	iReceivedTime.UniversalTime();
  1010 	iReceivedTime.UniversalTime();
       
  1011 	CLOG( ( ECookie, 0, _L( "<- CCookie::CCookie ") ) );
   850 	}
  1012 	}
   851 
  1013 
   852 
  1014 
   853 // ---------------------------------------------------------
  1015 // ---------------------------------------------------------
   854 // CCookie::ConstructL
  1016 // CCookie::ConstructL
   855 // ---------------------------------------------------------
  1017 // ---------------------------------------------------------
   856 //
  1018 //
   857 void CCookie::ConstructL( RHTTPHeaders aRequestHeaders, TInt aPartIndex,
  1019 void CCookie::ConstructL( RHTTPHeaders aRequestHeaders, TInt aPartIndex,
   858 						RStringF aFieldName, const TUriC8& aUri )
  1020 						RStringF aFieldName, const TUriC8& aUri )
   859 	{
  1021 	{
       
  1022 	CLOG( ( ECookie, 0, _L( "-> CCookie::ConstructL ") ) );
   860 	const TStringTable& commonStringTable = RHTTPSession::GetTable();
  1023 	const TStringTable& commonStringTable = RHTTPSession::GetTable();
   861 
  1024 
   862 	// Determining if this object is constructed from a Set-Cookie2 HTTP header
  1025 	// Determining if this object is constructed from a Set-Cookie2 HTTP header
   863 	RStringF setCookie2Name = iStringPool.StringF( HTTP::ESetCookie2,
  1026 	RStringF setCookie2Name = iStringPool.StringF( HTTP::ESetCookie2,
   864                                                    commonStringTable );
  1027                                                    commonStringTable );
  1158                 {
  1321                 {
  1159 		        // if the Port attrib does not exist, leave it blank
  1322 		        // if the Port attrib does not exist, leave it blank
  1160                 }
  1323                 }
  1161             }
  1324             }
  1162         }
  1325         }
       
  1326     CLOG( ( ECookie, 0, _L( "<- CCookie::ConstructL ") ) );
  1163 	}
  1327 	}
  1164 
  1328 
  1165 
  1329 
  1166 
  1330 
  1167 // ---------------------------------------------------------
  1331 // ---------------------------------------------------------
  1169 // ---------------------------------------------------------
  1333 // ---------------------------------------------------------
  1170 //
  1334 //
  1171 TInt CCookie::FindAttribute( TCookieAttributeName aAttributeName,
  1335 TInt CCookie::FindAttribute( TCookieAttributeName aAttributeName,
  1172 							TCookieAttribute& aAttribute ) const
  1336 							TCookieAttribute& aAttribute ) const
  1173 	{
  1337 	{
       
  1338 	CLOG( ( ECookie, 0, _L( "-> CCookie::FindAttribute ") ) );
  1174 	const TInt numAttributes = iAttributes.Count();
  1339 	const TInt numAttributes = iAttributes.Count();
  1175 	for ( TInt index = 0; index < numAttributes; ++index )
  1340 	for ( TInt index = 0; index < numAttributes; ++index )
  1176 		{
  1341 		{
  1177 		if ( iAttributes[index].Name() == aAttributeName )
  1342 		if ( iAttributes[index].Name() == aAttributeName )
  1178 			{
  1343 			{
  1179 			aAttribute = iAttributes[index];
  1344 			aAttribute = iAttributes[index];
       
  1345 			CLOG( ( ECookie, 0, _L( "<- CCookie::FindAttribute index : %d"),index ) );
  1180 			return index;
  1346 			return index;
  1181 			}
  1347 			}
  1182 		}
  1348 		}
  1183 
  1349 	CLOG( ( ECookie, 0, _L( "<- CCookie::FindAttribute KErrNotFound") ) );
  1184 	return KErrNotFound;
  1350 	return KErrNotFound;
  1185 	}
  1351 	}
  1186 
  1352 
  1187 // ---------------------------------------------------------
  1353 // ---------------------------------------------------------
  1188 // CCookie::RemoveAttribute
  1354 // CCookie::RemoveAttribute
  1189 // ---------------------------------------------------------
  1355 // ---------------------------------------------------------
  1190 //
  1356 //
  1191 void CCookie::RemoveAttribute( TInt aIndex )
  1357 void CCookie::RemoveAttribute( TInt aIndex )
  1192 	{
  1358 	{
       
  1359 	CLOG( ( ECookie, 0, _L( "-> CCookie::RemoveAttribute aIndex : %d"),aIndex ) );
  1193 	iSize -= ( KCookieAttributePrefixLength + iAttributes[ aIndex ].Size() + 
  1360 	iSize -= ( KCookieAttributePrefixLength + iAttributes[ aIndex ].Size() + 
  1194                KCookieAttributeDefaultedLength + 
  1361                KCookieAttributeDefaultedLength + 
  1195                KCookieAttributeFoundLength );
  1362                KCookieAttributeFoundLength );
  1196 	iAttributes[ aIndex ].Close();
  1363 	iAttributes[ aIndex ].Close();
  1197 	iAttributes.Remove( aIndex );
  1364 	iAttributes.Remove( aIndex );
       
  1365 	CLOG( ( ECookie, 0, _L( "<- CCookie::RemoveAttribute aIndex : %d"),aIndex ) );
  1198 	}
  1366 	}
  1199 
  1367 
  1200 // ---------------------------------------------------------
  1368 // ---------------------------------------------------------
  1201 // CCookie::RemoveAttribute
  1369 // CCookie::RemoveAttribute
  1202 // ---------------------------------------------------------
  1370 // ---------------------------------------------------------
  1203 //
  1371 //
  1204 void CCookie::RemoveAttribute( TCookieAttributeName aAttributeName )
  1372 void CCookie::RemoveAttribute( TCookieAttributeName aAttributeName )
  1205     {
  1373     {
       
  1374     CLOG( ( ECookie, 0, _L( "-> CCookie::RemoveAttribute - name: %d"), aAttributeName ) );
  1206     TCookieAttribute attribute;
  1375     TCookieAttribute attribute;
  1207     TInt index( FindAttribute( aAttributeName, attribute ) );
  1376     TInt index( FindAttribute( aAttributeName, attribute ) );
  1208     if( index != KErrNotFound )
  1377     if( index != KErrNotFound )
  1209         {
  1378         {
  1210         RemoveAttribute( index );
  1379         RemoveAttribute( index );
  1211         }
  1380         }
       
  1381     CLOG( ( ECookie, 0, _L( "<- CCookie::RemoveAttribute - name: %d, index: %d"), aAttributeName, index ) );
  1212     }
  1382     }
  1213 
  1383 
  1214 // ---------------------------------------------------------
  1384 // ---------------------------------------------------------
  1215 // CCookie::GetLocalOffset
  1385 // CCookie::GetLocalOffset
  1216 // ---------------------------------------------------------
  1386 // ---------------------------------------------------------
  1217 //
  1387 //
  1218 TInt CCookie::GetLocalOffset( HBufC8* aDate, TInt& aHour, 
  1388 TInt CCookie::GetLocalOffset( HBufC8* aDate, TInt& aHour, 
  1219                          TInt& aMinute, TInt& aLength ) const
  1389                          TInt& aMinute, TInt& aLength ) const
  1220     {
  1390     {
       
  1391     CLOG( ( ECookie, 0, _L( "-> CCookie::GetLocalOffset ") ) );
  1221     TInt retval( 0 );
  1392     TInt retval( 0 );
  1222     TInt pos(0);
  1393     TInt pos(0);
  1223 //    TInt fwspos(0);
  1394 //    TInt fwspos(0);
  1224 //    TBool plus( ETrue );
  1395 //    TBool plus( ETrue );
  1225     TPtrC8 datePtr( aDate->Des() );
  1396     TPtrC8 datePtr( aDate->Des() );
  1307         lex.Val( aHour );
  1478         lex.Val( aHour );
  1308         TLex8 lex1(temp->Right(2));
  1479         TLex8 lex1(temp->Right(2));
  1309         lex1.Val( aMinute );
  1480         lex1.Val( aMinute );
  1310         CleanupStack::PopAndDestroy( temp ); // temp
  1481         CleanupStack::PopAndDestroy( temp ); // temp
  1311         }
  1482         }
       
  1483     CLOG( ( ECookie, 0, _L( "<- CCookie::GetLocalOffset retval : %d "),retval ) );
  1312     return retval;
  1484     return retval;
  1313     }
  1485     }
  1314 
  1486 
  1315 
  1487 
  1316 
  1488 
  1319 // CCookie::GetMilitaryOffset
  1491 // CCookie::GetMilitaryOffset
  1320 // ---------------------------------------------------------
  1492 // ---------------------------------------------------------
  1321 //
  1493 //
  1322 TInt CCookie::GetMilitaryOffset( HBufC8* /*aDate*/, TInt& aHour ) const
  1494 TInt CCookie::GetMilitaryOffset( HBufC8* /*aDate*/, TInt& aHour ) const
  1323     {
  1495     {
       
  1496     CLOG( ( ECookie, 0, _L( "-> CCookie::GetMilitaryOffset  ") ) );
  1324     // TODO: Add military timezone handling here...
  1497     // TODO: Add military timezone handling here...
  1325     TInt retval( KErrNotFound );
  1498     TInt retval( KErrNotFound );
  1326     aHour = 0;
  1499     aHour = 0;
       
  1500     CLOG( ( ECookie, 0, _L( "<- CCookie::GetMilitaryOffset retval : %d "),retval ) );
  1327     return retval;
  1501     return retval;
  1328     }
  1502     }
  1329 
  1503 
  1330 
  1504 
  1331 
  1505 
  1334 // ---------------------------------------------------------
  1508 // ---------------------------------------------------------
  1335 //
  1509 //
  1336 TInt CCookie::GetTimeZone( HBufC8* aDate, TInt& aHour, 
  1510 TInt CCookie::GetTimeZone( HBufC8* aDate, TInt& aHour, 
  1337                          TInt& aLength ) const
  1511                          TInt& aLength ) const
  1338     {
  1512     {
       
  1513     CLOG( ( ECookie, 0, _L( "-> CCookie::GetTimeZone  ") ) );
  1339     TInt retval( 0 );
  1514     TInt retval( 0 );
  1340     TInt zonepos = aDate->Find( KUT() );
  1515     TInt zonepos = aDate->Find( KUT() );
  1341     if ( zonepos != KErrNotFound )
  1516     if ( zonepos != KErrNotFound )
  1342         {
  1517         {
  1343         aHour = 0;
  1518         aHour = 0;
  1422     if ( zonepos != KErrNotFound )
  1597     if ( zonepos != KErrNotFound )
  1423         {
  1598         {
  1424         // get the length
  1599         // get the length
  1425         aLength = aDate->Length() - zonepos;
  1600         aLength = aDate->Length() - zonepos;
  1426         }
  1601         }
  1427 
  1602     CLOG( ( ECookie, 0, _L( "<- CCookie::GetTimeZone retval :%d "),retval ) );
  1428     return retval;
  1603     return retval;
  1429     }
  1604     }
  1430 
  1605 
  1431 
  1606 
  1432 
  1607 
  1434 // CCookie::GetCleanedDateTimeLC
  1609 // CCookie::GetCleanedDateTimeLC
  1435 // ---------------------------------------------------------
  1610 // ---------------------------------------------------------
  1436 //
  1611 //
  1437 HBufC8* CCookie::GetCleanedDateTimeLC( HBufC8* aDate ) const
  1612 HBufC8* CCookie::GetCleanedDateTimeLC( HBufC8* aDate ) const
  1438     {
  1613     {
       
  1614     CLOG( ( ECookie, 0, _L( "-> CCookie::GetCleanedDateTimeLC ") ) );
  1439     // as http time might contain a "DayOfWeek," optional part
  1615     // as http time might contain a "DayOfWeek," optional part
  1440     // which is not understood by the parser, we need to 
  1616     // which is not understood by the parser, we need to 
  1441     // remove it 
  1617     // remove it 
  1442     TInt pos = aDate->Locate( KDayOfWeekSeparator );
  1618     TInt pos = aDate->Locate( KDayOfWeekSeparator );
  1443     if ( pos < 0 )
  1619     if ( pos < 0 )
  1500         { // locale offset
  1676         { // locale offset
  1501         }
  1677         }
  1502     *result = temp->Left( temp->Length() - length);
  1678     *result = temp->Left( temp->Length() - length);
  1503     // return ( temp->Left( temp->Length() - length).AllocLC() );
  1679     // return ( temp->Left( temp->Length() - length).AllocLC() );
  1504     CleanupStack::PopAndDestroy( temp );
  1680     CleanupStack::PopAndDestroy( temp );
       
  1681     CLOG( ( ECookie, 0, _L( "-> CCookie::GetCleanedDateTimeLC result : %d"),result ) );
  1505     return result;
  1682     return result;
  1506     }
  1683     }
  1507 
  1684 
  1508 
  1685 
  1509 
  1686 
  1518 											const THTTPHdrVal& aHdrVal, 
  1695 											const THTTPHdrVal& aHdrVal, 
  1519 											TBool aDefaulted )
  1696 											TBool aDefaulted )
  1520 : iName( aName ),
  1697 : iName( aName ),
  1521 iDefaulted( aDefaulted )
  1698 iDefaulted( aDefaulted )
  1522 	{
  1699 	{
       
  1700 	CLOG( ( ECookie, 0, _L( "-> CCookie::TCookieAttribute") ) );
  1523 	iValue = aHdrVal.Copy();
  1701 	iValue = aHdrVal.Copy();
  1524 	
  1702 	
  1525 
  1703 
  1526 	switch ( iValue.Type() )
  1704 	switch ( iValue.Type() )
  1527 		{
  1705 		{
  1528 		case THTTPHdrVal::KTIntVal :
  1706 		case THTTPHdrVal::KTIntVal :
  1529 			{
  1707 			{
  1530 			iSize = sizeof( TInt );
  1708 			iSize = sizeof( TInt );
       
  1709 			CLOG( ( ECookie, 0, _L( "-> CCookie::TCookieAttribute iSize :%d "),iSize ) );
  1531 			break;
  1710 			break;
  1532 			}
  1711 			}
  1533 		case THTTPHdrVal::KStrVal :
  1712 		case THTTPHdrVal::KStrVal :
  1534 			{
  1713 			{
  1535 			iSize = iValue.Str().DesC().Length();
  1714 			iSize = iValue.Str().DesC().Length();
       
  1715 			CLOG( ( ECookie, 0, _L( "-> CCookie::TCookieAttribute iSize :%d "),iSize ) );
  1536 			break;
  1716 			break;
  1537 			}
  1717 			}
  1538 		case THTTPHdrVal::KDateVal :
  1718 		case THTTPHdrVal::KDateVal :
  1539 			{
  1719 			{
  1540 			iSize = sizeof( TDateTime );
  1720 			iSize = sizeof( TDateTime );
       
  1721 			CLOG( ( ECookie, 0, _L( "-> CCookie::TCookieAttribute iSize :%d "),iSize ) );
  1541 			break;
  1722 			break;
  1542 			}
  1723 			}
  1543 		case THTTPHdrVal::KStrFVal :
  1724 		case THTTPHdrVal::KStrFVal :
  1544 			{
  1725 			{
  1545 			iSize = iValue.StrF().DesC().Length();
  1726 			iSize = iValue.StrF().DesC().Length();
       
  1727 			CLOG( ( ECookie, 0, _L( "-> CCookie::TCookieAttribute iSize :%d "),iSize ) );
  1546 			break;
  1728 			break;
  1547 			}
  1729 			}
  1548 		default :	// THTTPHdrVal::KNoType
  1730 		default :	// THTTPHdrVal::KNoType
  1549 			{
  1731 			{
  1550 			iSize = 0;
  1732 			iSize = 0;
       
  1733 			CLOG( ( ECookie, 0, _L( "-> CCookie::TCookieAttribute iSize :%d "),iSize ) );
  1551 			}
  1734 			}
  1552 		}
  1735 		}
       
  1736 	CLOG( ( ECookie, 0, _L( "<- CCookie::TCookieAttribute  ") ) );
  1553 	}
  1737 	}
  1554 
  1738 
  1555 
  1739 
  1556 // ---------------------------------------------------------
  1740 // ---------------------------------------------------------
  1557 // CCookie::TCookieAttribute::TCookieAttribute
  1741 // CCookie::TCookieAttribute::TCookieAttribute
  1558 // ---------------------------------------------------------
  1742 // ---------------------------------------------------------
  1559 //
  1743 //
  1560 CCookie::TCookieAttribute::TCookieAttribute()
  1744 CCookie::TCookieAttribute::TCookieAttribute()
  1561 	{
  1745 	{
       
  1746 	CLOG( ( ECookie, 0, _L( "-> CCookie::TCookieAttribute  ") ) );
       
  1747 	CLOG( ( ECookie, 0, _L( "<- CCookie::TCookieAttribute  ") ) );
  1562 	}
  1748 	}
  1563 
  1749 
  1564 
  1750 
  1565 // ---------------------------------------------------------
  1751 // ---------------------------------------------------------
  1566 // CCookie::TCookieAttribute::Close
  1752 // CCookie::TCookieAttribute::Close
  1567 // ---------------------------------------------------------
  1753 // ---------------------------------------------------------
  1568 //
  1754 //
  1569 void CCookie::TCookieAttribute::Close()
  1755 void CCookie::TCookieAttribute::Close()
  1570 	{
  1756 	{
       
  1757 	CLOG( ( ECookie, 0, _L( "-> CCookie::Close  ") ) );
  1571 	THTTPHdrVal::THTTPValType type = iValue.Type();
  1758 	THTTPHdrVal::THTTPValType type = iValue.Type();
  1572 	if ( type == THTTPHdrVal::KStrVal )
  1759 	if ( type == THTTPHdrVal::KStrVal )
  1573 		{
  1760 		{
       
  1761 		CLOG( ( ECookie, 0, _L( "-> CCookie::Close  KStrVal") ) );
  1574 		iValue.Str().Close();
  1762 		iValue.Str().Close();
  1575 		}
  1763 		}
  1576 	else if ( type == THTTPHdrVal::KStrFVal )
  1764 	else if ( type == THTTPHdrVal::KStrFVal )
  1577 		{
  1765 		{
       
  1766 		CLOG( ( ECookie, 0, _L( "-> CCookie::Close  KStrFVal") ) );
  1578 		iValue.StrF().Close();
  1767 		iValue.StrF().Close();
  1579 		}
  1768 		}
  1580 
  1769 
  1581 	// TBD : iValue = THTTPHdrVal();?
  1770 	// TBD : iValue = THTTPHdrVal();?
  1582 	iSize = 0;
  1771 	iSize = 0;
       
  1772 	CLOG( ( ECookie, 0, _L( "<- CCookie::Close  ") ) );
  1583 	}
  1773 	}
  1584 
  1774 
  1585 
  1775 
  1586 // ---------------------------------------------------------
  1776 // ---------------------------------------------------------
  1587 // CCookie::TCookieAttribute::Name
  1777 // CCookie::TCookieAttribute::Name