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 |
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 |
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 ); |
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() ); |
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 |