85 |
85 |
86 iEngine->Console().Printf(_L("\nStart of header codec tests")); |
86 iEngine->Console().Printf(_L("\nStart of header codec tests")); |
87 ResetTimeElapsed(); |
87 ResetTimeElapsed(); |
88 |
88 |
89 // Run tests on parsed -> OTA data conversions, for each header implemented |
89 // Run tests on parsed -> OTA data conversions, for each header implemented |
|
90 TestDecodeEncodeCacheControlL(); |
90 TestEncodeAcceptL(); |
91 TestEncodeAcceptL(); |
91 TestEncodeAcceptCharsetL(); |
92 TestEncodeAcceptCharsetL(); |
92 TestEncodeAuthorizationL(); |
93 TestEncodeAuthorizationL(); |
93 TestEncodeConnectionL(); |
94 TestEncodeConnectionL(); |
94 TestEncodeContentLengthL(); |
95 TestEncodeContentLengthL(); |
289 ReleaseHeaders(); |
290 ReleaseHeaders(); |
290 |
291 |
291 iEngine->Utils().LogIt ( _L ("\nTestDuplicateHeaderDecodingL test success.")); |
292 iEngine->Utils().LogIt ( _L ("\nTestDuplicateHeaderDecodingL test success.")); |
292 } |
293 } |
293 |
294 |
|
295 |
|
296 void CHttpHdrCodecTest::TestDecodeEncodeCacheControlL() |
|
297 { |
|
298 _LIT8(KCacheControlOTAVal, "private, max-age=360, must-revalidate"); |
|
299 RStringF cacheControl = iStrP.StringF(HTTP::ECacheControl,RHTTPSession::GetTable()); |
|
300 RStringF maxAge = iStrP.StringF(HTTP::EMaxAge,RHTTPSession::GetTable()); |
|
301 RHTTPHeaders hdr = GetHeadersLC(); |
|
302 hdr.SetRawFieldL(cacheControl, KCacheControlOTAVal, KFieldSeparator); |
|
303 if(hdr.FieldPartsL(cacheControl) != 3) |
|
304 { |
|
305 iEngine->Utils().LogIt(_L("\nCache-Control OTA comparison failed -> [parts != 3]")); |
|
306 User::Leave(KErrCorrupt); |
|
307 } |
|
308 THTTPHdrVal hVal; |
|
309 User::LeaveIfError(hdr.GetField(cacheControl,0,hVal)); |
|
310 if(hVal.StrF().DesC().Compare(_L8("private")) != 0) |
|
311 { |
|
312 iEngine->Utils().LogIt(_L("\nCache-Control OTA comparison failed -> [private]")); |
|
313 User::Leave(KErrCorrupt); |
|
314 } |
|
315 THTTPHdrVal paramVal; |
|
316 User::LeaveIfError(hdr.GetParam(cacheControl, maxAge, paramVal, 1)); |
|
317 if(paramVal.Int() != 360) |
|
318 { |
|
319 iEngine->Utils().LogIt(_L("\nCache-Control OTA comparison failed -> [300]")); |
|
320 User::Leave(KErrCorrupt); |
|
321 } |
|
322 THTTPHdrVal hVal2; |
|
323 User::LeaveIfError(hdr.GetField(cacheControl,2,hVal2)); |
|
324 if(hVal2.StrF().DesC().Compare(_L8("must-revalidate")) != 0) |
|
325 { |
|
326 iEngine->Utils().LogIt(_L("\nmust-revalidate OTA comparison failed -> [private, max-age=300, must-revalidate]")); |
|
327 User::Leave(KErrCorrupt); |
|
328 } |
|
329 |
|
330 TPtrC8 rawHeader; |
|
331 hdr.GetRawField(cacheControl, rawHeader); |
|
332 if(rawHeader.CompareF(KCacheControlOTAVal) != 0) |
|
333 { |
|
334 iEngine->Utils().LogIt(_L("\nmust-revalidate OTA comparison failed -> [300]")); |
|
335 User::Leave(KErrCorrupt); |
|
336 } |
|
337 |
|
338 ReleaseHeaders(); |
|
339 |
|
340 iEngine->Utils().LogIt ( _L ("\nTestDecodeEncodeCacheControlL test success.")); |
|
341 } |
294 |
342 |
295 void CHttpHdrCodecTest::TestEncodeAcceptL() |
343 void CHttpHdrCodecTest::TestEncodeAcceptL() |
296 { |
344 { |
297 // the result we expect and that we will validate |
345 // the result we expect and that we will validate |
298 _LIT8(KAcceptOTAVal, "text/html; q=0.8, text/vnd.wap.wml; q=0.2; extended=value, text/*"); |
346 _LIT8(KAcceptOTAVal, "text/html; q=0.8, text/vnd.wap.wml; q=0.2; extended=value, text/*"); |