|
1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "CPipeliningTestCase.h" |
|
17 #include "httptestutils.h" |
|
18 #include "CPipeliningTestParams.h" |
|
19 |
|
20 //Helper function to convert TPtr to TInt |
|
21 //declared as extern as it is already defined in |
|
22 //CPipeliningTestCaseParams.cpp as a static function |
|
23 static TInt Ptr2Int(const TDesC8& aPtr) |
|
24 { |
|
25 TInt aInt; |
|
26 TLex8 aLex(aPtr); |
|
27 aLex.Val(aInt); |
|
28 return aInt; |
|
29 } |
|
30 |
|
31 CPipeliningTestCase* CPipeliningTestCase::NewL(CHTTPTestUtils& aTestUtils, CPipeliningTestParams& aPipeliningTestParams) |
|
32 { |
|
33 CPipeliningTestCase* self = new (ELeave) CPipeliningTestCase(aTestUtils, aPipeliningTestParams); |
|
34 return self; |
|
35 } |
|
36 |
|
37 |
|
38 |
|
39 CPipeliningTestCase::CPipeliningTestCase(CHTTPTestUtils& aTestUtils, CPipeliningTestParams& aPipeliningTestParams) |
|
40 : iTestUtils(aTestUtils), iPipeliningTestParams(aPipeliningTestParams) |
|
41 { |
|
42 } |
|
43 |
|
44 |
|
45 |
|
46 CPipeliningTestCase::~CPipeliningTestCase() |
|
47 { |
|
48 } |
|
49 |
|
50 |
|
51 |
|
52 const TDesC& CPipeliningTestCase::TestCaseName() const |
|
53 { |
|
54 return iPipeliningTestParams.TestCaseName(); |
|
55 } |
|
56 |
|
57 |
|
58 |
|
59 TInt CPipeliningTestCase::TransactionCount(TInt aConnectionIndex) const |
|
60 { |
|
61 return iPipeliningTestParams.TransactionCount(aConnectionIndex); |
|
62 } |
|
63 |
|
64 |
|
65 |
|
66 TInt CPipeliningTestCase::TotalTransactionCount() const |
|
67 { |
|
68 return iPipeliningTestParams.TotalTransactionCount(); |
|
69 } |
|
70 |
|
71 |
|
72 |
|
73 TBool CPipeliningTestCase::BatchTransactions() const |
|
74 { |
|
75 return ETrue; |
|
76 } |
|
77 |
|
78 |
|
79 |
|
80 TInt CPipeliningTestCase::ConnectionCount() const |
|
81 { |
|
82 return iPipeliningTestParams.ConnectionCount(); |
|
83 } |
|
84 |
|
85 TInt CPipeliningTestCase::ErrorVal() const |
|
86 { |
|
87 return iPipeliningTestParams.Error(); |
|
88 } |
|
89 |
|
90 RHTTPTransaction CPipeliningTestCase::GetTransactionL(TInt aIndex, RHTTPSession aSession, MHTTPTransactionCallback& aClient) |
|
91 { |
|
92 __ASSERT_ALWAYS( aIndex < iPipeliningTestParams.TotalTransactionCount(), User::Invariant()); |
|
93 |
|
94 if(iPipeliningTestParams.TestCaseName().Compare(_L("IOP TEST CASE 6")) == 0) |
|
95 { |
|
96 _LIT8(KTxtUri, "http://127.0.0.1"); |
|
97 TUriParser8 uri; |
|
98 uri.Parse(KTxtUri()); |
|
99 |
|
100 RStringF method = aSession.StringPool().StringF(HTTP::EPOST,RHTTPSession::GetTable()); |
|
101 RHTTPTransaction trans = aSession.OpenTransactionL(uri, aClient, method); |
|
102 RHTTPHeaders headers = trans.Request().GetHeaderCollection(); |
|
103 |
|
104 |
|
105 _LIT8(KTxtHeaderName0, "Expect"); |
|
106 _LIT8(KTxtHeaderValue0, "100-Continue"); |
|
107 RStringF headerStrName0 = aSession.StringPool().OpenFStringL(KTxtHeaderName0()); |
|
108 CleanupClosePushL(headerStrName0); |
|
109 RStringF headerStrValue0 = aSession.StringPool().OpenFStringL(KTxtHeaderValue0()); |
|
110 CleanupClosePushL(headerStrValue0); |
|
111 THTTPHdrVal headerValue0(headerStrValue0); |
|
112 headers.SetFieldL(headerStrName0, headerValue0); |
|
113 CleanupStack::PopAndDestroy(2, &headerStrName0); |
|
114 return trans; |
|
115 } |
|
116 |
|
117 else if((iPipeliningTestParams.TestCaseName().Compare(_L("Test Case INC078630")) == 0) || (iPipeliningTestParams.TestCaseName().Compare(_L("Performance Test Case 8")) == 0)) |
|
118 { |
|
119 |
|
120 _LIT8(KTxtUri, "Microsoft-Server-ActiveSync?DeviceId=Foo&DeviceType=9999&Cmd=Ping"); |
|
121 TUriParser8 uri; |
|
122 uri.Parse(KTxtUri()); |
|
123 |
|
124 |
|
125 RStringF method = aSession.StringPool().StringF(HTTP::EPOST,RHTTPSession::GetTable()); |
|
126 RHTTPTransaction trans = aSession.OpenTransactionL(uri, aClient, method); |
|
127 RHTTPHeaders headers = trans.Request().GetHeaderCollection(); |
|
128 |
|
129 |
|
130 _LIT8(KTxtHeaderName0, "Host"); |
|
131 _LIT8(KTxtHeaderValue0, "127.0.0.1"); |
|
132 RStringF headerStrName0 = aSession.StringPool().OpenFStringL(KTxtHeaderName0()); |
|
133 CleanupClosePushL(headerStrName0); |
|
134 RStringF headerStrValue0 = aSession.StringPool().OpenFStringL(KTxtHeaderValue0()); |
|
135 CleanupClosePushL(headerStrValue0); |
|
136 THTTPHdrVal headerValue0(headerStrValue0); |
|
137 headers.SetFieldL(headerStrName0, headerValue0); |
|
138 CleanupStack::PopAndDestroy(2, &headerStrName0); |
|
139 |
|
140 _LIT8(KTxtHeaderName, "Accept-Language"); |
|
141 _LIT8(KTxtHeaderValue, "en-us"); |
|
142 RStringF headerStrName = aSession.StringPool().OpenFStringL(KTxtHeaderName()); |
|
143 CleanupClosePushL(headerStrName); |
|
144 RStringF headerStrValue = aSession.StringPool().OpenFStringL(KTxtHeaderValue()); |
|
145 CleanupClosePushL(headerStrValue); |
|
146 THTTPHdrVal headerValue(headerStrValue); |
|
147 headers.SetFieldL(headerStrName, headerValue); |
|
148 CleanupStack::PopAndDestroy(2, &headerStrName); |
|
149 |
|
150 _LIT8(KTxtHeaderName1, "MS-ASProtocolVersion"); |
|
151 _LIT8(KTxtHeaderValue1, "2.5"); |
|
152 RStringF headerStrName1 = aSession.StringPool().OpenFStringL(KTxtHeaderName1()); |
|
153 CleanupClosePushL(headerStrName1); |
|
154 RStringF headerStrValue1 = aSession.StringPool().OpenFStringL(KTxtHeaderValue1()); |
|
155 CleanupClosePushL(headerStrValue1); |
|
156 THTTPHdrVal headerValue1(headerStrValue1); |
|
157 headers.SetFieldL(headerStrName1, headerValue1); |
|
158 CleanupStack::PopAndDestroy(2, &headerStrName1); |
|
159 |
|
160 return trans; |
|
161 |
|
162 } |
|
163 else if(iPipeliningTestParams.TestCaseName().Compare(_L("Performance Test Case 9")) == 0) |
|
164 { |
|
165 |
|
166 _LIT8(KTxtUri, "http://www.newlc.com/Symbian-OS-Error-Codes.html"); |
|
167 TUriParser8 uri; |
|
168 uri.Parse(KTxtUri()); |
|
169 |
|
170 |
|
171 RStringF method = aSession.StringPool().StringF(HTTP::EPOST,RHTTPSession::GetTable()); |
|
172 RHTTPTransaction trans = aSession.OpenTransactionL(uri, aClient, method); |
|
173 RHTTPHeaders headers = trans.Request().GetHeaderCollection(); |
|
174 |
|
175 _LIT8(KTxtHeaderName3, "Host"); |
|
176 _LIT8(KTxtHeaderValue3, "194.146.227.34"); |
|
177 RStringF headerStrName3 = aSession.StringPool().OpenFStringL(KTxtHeaderName3()); |
|
178 CleanupClosePushL(headerStrName3); |
|
179 RStringF headerStrValue3 = aSession.StringPool().OpenFStringL(KTxtHeaderValue3()); |
|
180 CleanupClosePushL(headerStrValue3); |
|
181 THTTPHdrVal headerValue3(headerStrValue3); |
|
182 headers.SetFieldL(headerStrName3, headerValue3); |
|
183 CleanupStack::PopAndDestroy(2, &headerStrName3); |
|
184 |
|
185 _LIT8(KTxtHeaderName1, "Content-Type"); |
|
186 _LIT8(KTxtHeaderValue1, "*/*"); |
|
187 RStringF headerStrName1 = aSession.StringPool().OpenFStringL(KTxtHeaderName1()); |
|
188 CleanupClosePushL(headerStrName1); |
|
189 RStringF headerStrValue1 = aSession.StringPool().OpenFStringL(KTxtHeaderValue1()); |
|
190 CleanupClosePushL(headerStrValue1); |
|
191 THTTPHdrVal headerValue1(headerStrValue1); |
|
192 headers.SetFieldL(headerStrName1, headerValue1); |
|
193 CleanupStack::PopAndDestroy(2, &headerStrName1); |
|
194 |
|
195 //Set the body data |
|
196 //The Content-Length will be set to 14 |
|
197 if (iFormEncoder) |
|
198 { |
|
199 delete iFormEncoder; |
|
200 iFormEncoder = NULL; |
|
201 } |
|
202 |
|
203 iFormEncoder = CHTTPFormEncoder::NewL(); |
|
204 TBuf8<256> name8; |
|
205 TBuf8<256> value8; |
|
206 _LIT(KName, "recherche"); |
|
207 _LIT(KValue, "asdf"); |
|
208 name8.Copy(KName); |
|
209 value8.Copy(KValue); |
|
210 iFormEncoder->AddFieldL(name8, value8); |
|
211 |
|
212 MHTTPDataSupplier* dataSupplier = this; |
|
213 dataSupplier = iFormEncoder; |
|
214 trans.Request().SetBody(*dataSupplier); |
|
215 |
|
216 return trans; |
|
217 |
|
218 } |
|
219 |
|
220 |
|
221 TInt transType = iPipeliningTestParams.TransactionSequenceArray(aIndex); |
|
222 |
|
223 // Check the transaction type to see if its a HTTP 1.0 transaction |
|
224 // if 1.0 transaction then |
|
225 // change the session properties for transaction 1 |
|
226 |
|
227 // Check the value for the TransactionList header in the ini file if it carries a value |
|
228 // other than 1 at the position described by aIndex for the particular test case |
|
229 if ( (transType != 1) && (aIndex == 0)) |
|
230 { |
|
231 TransInfo thisTransInfo = iPipeliningTestParams.TransactionType(transType); |
|
232 |
|
233 TInt valueForHttpHdr = thisTransInfo.TransHeaderTypeArr[EHttpHeader]; |
|
234 if (( valueForHttpHdr != (ENoHeader) ) ) |
|
235 { |
|
236 if ((thisTransInfo.TransHeaderInfoPtrArr[valueForHttpHdr])->Des().Compare(_L("1.0"))) |
|
237 { |
|
238 RHTTPConnectionInfo connInfo = aSession.ConnectionInfo(); |
|
239 RStringPool strPool = aSession.StringPool(); |
|
240 THTTPHdrVal http10( strPool.StringF( HTTP::EHttp10, RHTTPSession::GetTable() ) ); |
|
241 connInfo.SetPropertyL( strPool.StringF( HTTP::EHTTPVersion,RHTTPSession::GetTable() ), http10 ); |
|
242 } |
|
243 } |
|
244 } |
|
245 |
|
246 //Check the request method type |
|
247 RStringF method; |
|
248 if(iPipeliningTestParams.ReqMethod().Compare(_L("HEAD")) == 0) |
|
249 { |
|
250 method = aSession.StringPool().StringF(HTTP::EHEAD,RHTTPSession::GetTable()); |
|
251 } |
|
252 else if(iPipeliningTestParams.ReqMethod().Compare(_L("POST")) == 0) |
|
253 { |
|
254 method = aSession.StringPool().StringF(HTTP::EPOST,RHTTPSession::GetTable()); |
|
255 } |
|
256 else if(iPipeliningTestParams.ReqMethod().Compare(_L("GET")) == 0) |
|
257 { |
|
258 method = aSession.StringPool().StringF(HTTP::EGET,RHTTPSession::GetTable()); |
|
259 } |
|
260 else if(iPipeliningTestParams.ReqMethod().Compare(_L("OPTIONS")) == 0) |
|
261 { |
|
262 method = aSession.StringPool().StringF(HTTP::EOPTIONS,RHTTPSession::GetTable()); |
|
263 } |
|
264 TInt aTempIndex(0); |
|
265 TInt uriCount(iPipeliningTestParams.UriCount()); |
|
266 aTempIndex = (uriCount > 1) ? aIndex : (uriCount-1); |
|
267 |
|
268 TUriParser8 uri; |
|
269 uri.Parse(iPipeliningTestParams.UriL(aTempIndex)); |
|
270 |
|
271 if ((iPipeliningTestParams.BatchingEnabled() == 1) && (iBatchingBufferSizeSet == 1)) |
|
272 { |
|
273 TInt bufferSize = iPipeliningTestParams.BufferSize(); |
|
274 RHTTPConnectionInfo connInfo = aSession.ConnectionInfo(); |
|
275 connInfo.SetPropertyL(aSession.StringPool().StringF(HTTP::EBatchingBufferSize,RHTTPSession::GetTable()), bufferSize); |
|
276 } |
|
277 |
|
278 if( (iPipeliningTestParams.Error() == KErrCancel) && (iPipeliningTestParams.TransactionSequenceArray(aIndex) == 2 )) |
|
279 { |
|
280 iTransToCancel = aSession.OpenTransactionL(uri, aClient, method); |
|
281 return iTransToCancel; |
|
282 } |
|
283 |
|
284 // Check the value for the TransactionList header in the ini file if it carries a value |
|
285 // other than 1 at the position described by aIndex for the particular test case |
|
286 else if ( transType != 1 ) |
|
287 { |
|
288 //Get the transaction info |
|
289 TransInfo thisTransInfo = iPipeliningTestParams.TransactionType(transType); |
|
290 |
|
291 //Check if there is a Cancel transaction |
|
292 TInt valueForTransactionHdr = thisTransInfo.TransHeaderTypeArr[ETransactionHeader]; |
|
293 if (( valueForTransactionHdr != ENoHeader ) ) |
|
294 { |
|
295 if ((thisTransInfo.TransHeaderInfoPtrArr[valueForTransactionHdr])->Des().Compare(_L("Cancel"))) |
|
296 { |
|
297 iTransToCancel = aSession.OpenTransactionL(uri, aClient, method); |
|
298 return iTransToCancel; |
|
299 } |
|
300 } |
|
301 |
|
302 //Create a plain-vanilla transaction |
|
303 RHTTPTransaction trans = aSession.OpenTransactionL(uri, aClient, method); |
|
304 |
|
305 //Check if there is a connection header |
|
306 TInt valueForConnectionHdr = thisTransInfo.TransHeaderTypeArr[::EConnectionHeader]; |
|
307 if (( valueForConnectionHdr != ENoHeader ) ) |
|
308 { |
|
309 if ( ( thisTransInfo.TransHeaderInfoPtrArr[valueForConnectionHdr])->Des().Compare(_L("Close") ) ) |
|
310 { |
|
311 AddConnectionCloseHeaderL(trans); |
|
312 } |
|
313 } |
|
314 |
|
315 |
|
316 TInt valueForBatchingHdr = thisTransInfo.TransHeaderTypeArr[EBatchingHeader]; |
|
317 if (( valueForBatchingHdr != ENoHeader ) && (thisTransInfo.TransHeaderInfoPtrArr[valueForBatchingHdr])->Des().Compare(_L("True")) )//Transaction needs a large header |
|
318 { |
|
319 // Add a fairly large header |
|
320 |
|
321 RHTTPHeaders headers = trans.Request().GetHeaderCollection(); |
|
322 |
|
323 _LIT8(KTxtHeaderName, "This_Is_A_Long_Header_Name"); |
|
324 _LIT8(KTxtHeaderValue, "This_Is_A_Long_Header_Value_abcdefghijklmnopqrstuvwxyz1234567890"); |
|
325 RStringF headerStrName = aSession.StringPool().OpenFStringL(KTxtHeaderName()); |
|
326 CleanupClosePushL(headerStrName); |
|
327 RStringF headerStrValue = aSession.StringPool().OpenFStringL(KTxtHeaderValue()); |
|
328 CleanupClosePushL(headerStrValue); |
|
329 THTTPHdrVal headerValue(headerStrValue); |
|
330 headers.SetFieldL(headerStrName, headerValue); |
|
331 CleanupStack::PopAndDestroy(2, &headerStrName); |
|
332 |
|
333 } |
|
334 return trans; |
|
335 } |
|
336 |
|
337 return aSession.OpenTransactionL(uri, aClient, method); |
|
338 } |
|
339 |
|
340 |
|
341 TBool CPipeliningTestCase::GetNextDataPart(TPtrC8& /*aDataPart*/) |
|
342 { |
|
343 return 0; |
|
344 } |
|
345 |
|
346 void CPipeliningTestCase::ReleaseData() |
|
347 { |
|
348 |
|
349 } |
|
350 TInt CPipeliningTestCase::OverallDataSize() |
|
351 { |
|
352 return 0; |
|
353 } |
|
354 TInt CPipeliningTestCase::Reset() |
|
355 { |
|
356 return 0; |
|
357 } |
|
358 const TDesC8& CPipeliningTestCase::GetRawRequest(TInt aConnectionIndex, TInt aTransIndex) |
|
359 { |
|
360 __ASSERT_ALWAYS( (aTransIndex<iPipeliningTestParams.TotalTransactionCount()) && (aConnectionIndex < iPipeliningTestParams.ConnectionCount()), User::Invariant()); |
|
361 |
|
362 return iPipeliningTestParams.RawRequest(aConnectionIndex, aTransIndex); |
|
363 } |
|
364 |
|
365 |
|
366 |
|
367 |
|
368 const TDesC8& CPipeliningTestCase::GetRawResponse(TInt aConnectionIndex, TInt aTransIndex) |
|
369 { |
|
370 __ASSERT_ALWAYS( (aTransIndex<iPipeliningTestParams.TotalTransactionCount()) && (aConnectionIndex < iPipeliningTestParams.ConnectionCount()), User::Invariant()); |
|
371 |
|
372 return iPipeliningTestParams.RawResponse(aConnectionIndex, aTransIndex); |
|
373 } |
|
374 |
|
375 |
|
376 |
|
377 |
|
378 void CPipeliningTestCase::AddConnectionCloseHeaderL(RHTTPTransaction aTransaction) |
|
379 { |
|
380 RStringF name = aTransaction.Session().StringPool().StringF(HTTP::EConnection, RHTTPSession::GetTable()); |
|
381 THTTPHdrVal value = aTransaction.Session().StringPool().StringF(HTTP::EClose, RHTTPSession::GetTable()); |
|
382 |
|
383 aTransaction.Request().GetHeaderCollection().SetFieldL(name, value); |
|
384 } |
|
385 |
|
386 |
|
387 |
|
388 |
|
389 TInt CPipeliningTestCase::RealExpectedConnectionCount() const |
|
390 { |
|
391 TInt numUris = iPipeliningTestParams.UriCount(); |
|
392 _LIT8(KTxtUri, "http://127.0.0.1"); |
|
393 //Check if the number of URIs in the ini file is more than one for the particular test case |
|
394 if ( numUris != 1) |
|
395 { |
|
396 TInt numLocalConnections = 0; |
|
397 TInt numExternalConnections = 0; |
|
398 for (TInt ii = 0; ii < numUris ; ++ ii) |
|
399 { |
|
400 TPtrC8 thisUri; |
|
401 TRAPD(err,thisUri.Set(iPipeliningTestParams.UriL(ii))); |
|
402 if(err != KErrArgument) |
|
403 { |
|
404 if (thisUri.Compare(KTxtUri) == 0) |
|
405 { |
|
406 ++numLocalConnections; |
|
407 } |
|
408 else |
|
409 { |
|
410 ++numExternalConnections; |
|
411 } |
|
412 } |
|
413 } |
|
414 |
|
415 TInt totalConnections = numLocalConnections + ((numExternalConnections != 0) ? 1:0); |
|
416 return totalConnections + 1; |
|
417 } |
|
418 else |
|
419 { |
|
420 TPtrC8 firstUri; |
|
421 TRAPD(err,firstUri.Set(iPipeliningTestParams.UriL(0))); |
|
422 if(err != KErrArgument) |
|
423 { |
|
424 if (firstUri.Compare(KTxtUri) == 0) |
|
425 { |
|
426 return iPipeliningTestParams.ConnectionCount(); |
|
427 } |
|
428 else |
|
429 { |
|
430 return 1; |
|
431 } |
|
432 } |
|
433 } |
|
434 return 0; |
|
435 } |
|
436 |
|
437 |
|
438 TInt CPipeliningTestCase::ExpectedError(RHTTPTransaction aTrans) |
|
439 { |
|
440 if (iPipeliningTestParams.Error() == KErrCancel) |
|
441 { |
|
442 if(!iIsTransCancelled) |
|
443 { |
|
444 if(aTrans.Id() == 3) |
|
445 { |
|
446 iTransToCancel.Cancel(); |
|
447 iIsTransCancelled = ETrue; |
|
448 iPipeliningTestParams.DecreaseTotalTransactionCount(); |
|
449 } |
|
450 } |
|
451 |
|
452 if( iTransToCancel.Id() == aTrans.Id() ) |
|
453 { |
|
454 return KErrCancel; |
|
455 } |
|
456 } |
|
457 else if ( iPipeliningTestParams.Error() == KErrDisconnected) |
|
458 { |
|
459 return KErrDisconnected; |
|
460 } |
|
461 |
|
462 return KErrNone; |
|
463 } |
|
464 |
|
465 void CPipeliningTestCase::ProcessHeadersL(RHTTPTransaction aTrans) |
|
466 { |
|
467 |
|
468 _LIT(KTxtFailed, "**TEST FAILED**"); |
|
469 _LIT(KExpectedValue, "Expected Value: %S"); |
|
470 _LIT(KActualValue, "Actual Value: %S"); |
|
471 _LIT(KExpectedLength, "Expected Content Length: %d"); |
|
472 _LIT(KActualLength, "Actual Content Length: %d"); |
|
473 |
|
474 |
|
475 if ( iPipeliningTestParams.ProcessHeader() ) |
|
476 { |
|
477 TInt numHdrs = iPipeliningTestParams.NumHdrs(); |
|
478 |
|
479 for (TInt xx=0; xx < numHdrs; ++xx ) |
|
480 { |
|
481 //Check if the header to process is WWW-Authenticate |
|
482 if((iPipeliningTestParams.HeaderToProcess(xx).Compare(_L8("WWW-Authenticate"))) == 0) |
|
483 { |
|
484 RStringPool stringPool = aTrans.Session().StringPool(); |
|
485 RHTTPHeaders headers = aTrans.Response().GetHeaderCollection(); |
|
486 RStringF headerStr = stringPool.StringF(HTTP::EWWWAuthenticate, aTrans.Session().GetTable()); |
|
487 FieldCompareL(headers.FieldPartsL(headerStr), iPipeliningTestParams.NumberOfHeaderVals(xx)); |
|
488 FieldValueCompareL(headers, headers.FieldPartsL(headerStr), xx, headerStr); |
|
489 } |
|
490 |
|
491 //Check if the header to process is Upgrade |
|
492 else if ( (iPipeliningTestParams.HeaderToProcess(xx).Compare(_L8("Upgrade"))) == 0 ) |
|
493 { |
|
494 RStringPool stringPool = aTrans.Session().StringPool(); |
|
495 RHTTPHeaders headers = aTrans.Response().GetHeaderCollection(); |
|
496 RStringF headerStr = stringPool.StringF(HTTP::EUpgrade, aTrans.Session().GetTable()); |
|
497 FieldCompareL(headers.FieldPartsL(headerStr), iPipeliningTestParams.NumberOfHeaderVals(xx)); |
|
498 FieldValueCompareL(headers, headers.FieldPartsL(headerStr), xx, headerStr); |
|
499 } |
|
500 |
|
501 //Check if the header to process is Content-Language |
|
502 else if ( (iPipeliningTestParams.HeaderToProcess(xx).Compare(_L8("Content-Language"))) == 0 ) |
|
503 { |
|
504 RStringPool stringPool = aTrans.Session().StringPool(); |
|
505 RHTTPHeaders headers = aTrans.Response().GetHeaderCollection(); |
|
506 RStringF headerStr = stringPool.StringF(HTTP::EContentLanguage, aTrans.Session().GetTable()); |
|
507 FieldCompareL(headers.FieldPartsL(headerStr), iPipeliningTestParams.NumberOfHeaderVals(xx)); |
|
508 FieldValueCompareL(headers, headers.FieldPartsL(headerStr), xx, headerStr); |
|
509 } |
|
510 |
|
511 //Check if the header to process is Server |
|
512 else if ( (iPipeliningTestParams.HeaderToProcess(xx).Compare(_L8("Server"))) == 0 ) |
|
513 { |
|
514 RStringPool stringPool = aTrans.Session().StringPool(); |
|
515 RHTTPHeaders headers = aTrans.Response().GetHeaderCollection(); |
|
516 RStringF headerStr = stringPool.StringF(HTTP::EServer, aTrans.Session().GetTable()); |
|
517 FieldCompareL(headers.FieldPartsL(headerStr), iPipeliningTestParams.NumberOfHeaderVals(xx)); |
|
518 FieldValueCompareL(headers, headers.FieldPartsL(headerStr), xx, headerStr); |
|
519 } |
|
520 |
|
521 //Check if the header to process is Host |
|
522 else if ( (iPipeliningTestParams.HeaderToProcess(xx).Compare(_L8("Host"))) == 0 ) |
|
523 { |
|
524 RStringPool stringPool = aTrans.Session().StringPool(); |
|
525 RHTTPHeaders headers = aTrans.Request().GetHeaderCollection(); |
|
526 THTTPHdrVal hdrVal; |
|
527 TBuf<100> buf1, buf2; |
|
528 RStringF headerStr = stringPool.StringF(HTTP::EHost, aTrans.Session().GetTable()); |
|
529 FieldValueCompareL(headers, 1, xx, headerStr); |
|
530 } |
|
531 |
|
532 //Check if the header to process is Content-Length |
|
533 else if ( (iPipeliningTestParams.HeaderToProcess(xx).Compare(_L8("Content-Length"))) == 0 ) |
|
534 { |
|
535 RStringPool stringPool = aTrans.Session().StringPool(); |
|
536 RHTTPHeaders headers = aTrans.Response().GetHeaderCollection(); |
|
537 THTTPHdrVal hdrVal; |
|
538 |
|
539 //Check Content-Length header parameter is stored correctly |
|
540 RStringF headerStr = stringPool.StringF(HTTP::EContentLength, aTrans.Session().GetTable()); |
|
541 User::LeaveIfError(headers.GetField(headerStr,0,hdrVal)); |
|
542 |
|
543 FieldCompareL(headers.FieldPartsL(headerStr), iPipeliningTestParams.NumberOfHeaderVals(xx)); |
|
544 |
|
545 if (hdrVal.Int() != Ptr2Int(iPipeliningTestParams.HeaderVal(xx+1,1)) ) |
|
546 { |
|
547 iTestUtils.LogIt(KExpectedLength, hdrVal.Int()); |
|
548 iTestUtils.LogIt(KActualLength, Ptr2Int(iPipeliningTestParams.HeaderVal(xx + 1,1))); |
|
549 iTestUtils.LogIt(KTxtFailed); |
|
550 User::Leave(KErrArgument); |
|
551 } |
|
552 iTestUtils.LogIt(KExpectedLength, hdrVal.Int()); |
|
553 iTestUtils.LogIt(KActualLength, Ptr2Int(iPipeliningTestParams.HeaderVal(xx + 1,1))); |
|
554 } |
|
555 |
|
556 //Check if the header to process is Content-Type |
|
557 else if ( (iPipeliningTestParams.HeaderToProcess(xx).Compare(_L8("Content-Type"))) == 0 ) |
|
558 { |
|
559 RStringPool stringPool = aTrans.Session().StringPool(); |
|
560 RHTTPHeaders headers = aTrans.Response().GetHeaderCollection(); |
|
561 THTTPHdrVal hdrVal; |
|
562 TBuf<100> buf1, buf2; |
|
563 |
|
564 RStringF headerStr = stringPool.StringF(HTTP::EContentType, aTrans.Session().GetTable()); |
|
565 |
|
566 FieldCompareL(headers.FieldPartsL(headerStr), iPipeliningTestParams.NumberOfHeaderVals(xx)); |
|
567 |
|
568 for ( TInt mn =0; mn < headers.FieldPartsL(headerStr); ++mn) |
|
569 { |
|
570 User::LeaveIfError(headers.GetField(headerStr,mn,hdrVal)); |
|
571 TPtrC8 ptrValue1 ( hdrVal.StrF ().DesC() ); |
|
572 if (TInt mno = ptrValue1.Compare(iPipeliningTestParams.HeaderVal(xx+1,mn+1)) != 0) |
|
573 { |
|
574 buf1.Copy(ptrValue1); |
|
575 buf2.Copy(iPipeliningTestParams.HeaderVal(xx + 1,mn + 1)); |
|
576 iTestUtils.LogIt(KExpectedValue, &buf1); |
|
577 iTestUtils.LogIt(KActualValue, &buf2); |
|
578 iTestUtils.LogIt(KTxtFailed); |
|
579 User::Leave(KErrArgument); |
|
580 } |
|
581 buf1.Copy(ptrValue1); |
|
582 buf2.Copy(iPipeliningTestParams.HeaderVal(xx + 1,mn + 1)); |
|
583 iTestUtils.LogIt(KExpectedValue, &buf1); |
|
584 iTestUtils.LogIt(KActualValue, &buf2); |
|
585 |
|
586 /* |
|
587 RStringF param = stringPool.StringF(HTTP::ECharset, aTrans.Session().GetTable()); |
|
588 THTTPHdrVal paramval; |
|
589 User::LeaveIfError(headers.GetParam(headerStr, param, paramval, mn)); |
|
590 TPtrC8 paramval1(paramval.StrF().DesC()); |
|
591 TBuf<100> buf3; |
|
592 buf3.Copy(paramval1); |
|
593 _LIT(KTxtParam, "Parameter Charset= %S"); |
|
594 iTestUtils.LogIt(KTxtParam, &buf3); |
|
595 */ |
|
596 } |
|
597 } |
|
598 |
|
599 //Check if the header to process is Date |
|
600 else if ( (iPipeliningTestParams.HeaderToProcess(xx).Compare(_L8("Date"))) == 0 ) |
|
601 { |
|
602 RStringPool stringPool = aTrans.Session().StringPool(); |
|
603 RHTTPHeaders headers = aTrans.Response().GetHeaderCollection(); |
|
604 THTTPHdrVal hdrVal; |
|
605 |
|
606 RStringF headerStr = stringPool.StringF(HTTP::EDate, aTrans.Session().GetTable()); |
|
607 |
|
608 if( headers.FieldPartsL(headerStr) != iPipeliningTestParams.NumberOfHeaderVals(xx)) |
|
609 { |
|
610 User::Leave(KErrArgument); |
|
611 } |
|
612 |
|
613 for ( TInt mn =0; mn < headers.FieldPartsL(headerStr); ++mn) |
|
614 { |
|
615 User::LeaveIfError(headers.GetField(headerStr,mn,hdrVal)); |
|
616 TDateTime rdt = hdrVal.DateTime(); |
|
617 } |
|
618 } |
|
619 |
|
620 //Check if the header to process is MsgBody |
|
621 else if ( (iPipeliningTestParams.HeaderToProcess(xx).Compare(_L8("MsgBody"))) == 0 ) |
|
622 { |
|
623 RStringPool stringPool = aTrans.Session().StringPool(); |
|
624 THTTPHdrVal hdrval; |
|
625 |
|
626 if(aTrans.Response().HasBody()) |
|
627 { |
|
628 _LIT(KStrHasBody, "Response stream has a body"); |
|
629 iTestUtils.LogIt(KStrHasBody); |
|
630 } |
|
631 else |
|
632 { |
|
633 _LIT(KStrNoBody, "Response stream has no body"); |
|
634 iTestUtils.LogIt(KStrNoBody); |
|
635 } |
|
636 |
|
637 if ( iPipeliningTestParams.HeaderVal(xx+1, 1).Compare(_L8("Null")) == 0) |
|
638 { |
|
639 TBool hasBody = aTrans.Response().HasBody(); |
|
640 if ( hasBody ) |
|
641 { |
|
642 _LIT(KTxtExpectedMsg, "Expected message body: NULL"); |
|
643 iTestUtils.LogIt(KTxtExpectedMsg); |
|
644 iTestUtils.LogIt(KTxtFailed); |
|
645 User::Leave(KErrArgument); |
|
646 } |
|
647 else |
|
648 { |
|
649 _LIT(KTxtHasBody, "Message Body: NULL"); |
|
650 iTestUtils.LogIt(KTxtHasBody); |
|
651 } |
|
652 } |
|
653 } |
|
654 } |
|
655 } |
|
656 } |
|
657 |
|
658 TBool CPipeliningTestCase::EnableBatching() const |
|
659 { |
|
660 return iPipeliningTestParams.BatchingEnabled(); |
|
661 } |
|
662 |
|
663 /** |
|
664 Compares the number fields in the String pool with those provided in the ini file |
|
665 @param aStringPool |
|
666 The String Pool |
|
667 @param aIniFile |
|
668 The fields from the ini file |
|
669 @leave |
|
670 KErrArgument if the number of fields in the ini file do not match those from the string pool |
|
671 */ |
|
672 void CPipeliningTestCase::FieldCompareL(TInt aStringPool, TInt aIniFile) |
|
673 { |
|
674 |
|
675 _LIT(KExpectedFields, "Expected number of fields: %d"); |
|
676 _LIT(KActualFields, "Actual number of fields: %d"); |
|
677 _LIT(KTxtFailed, "**TEST FAILED**"); |
|
678 |
|
679 if( aStringPool != aIniFile) |
|
680 { |
|
681 iTestUtils.LogIt(KExpectedFields,aStringPool ); |
|
682 iTestUtils.LogIt(KActualFields, aIniFile); |
|
683 iTestUtils.LogIt(KTxtFailed); |
|
684 User::Leave(KErrArgument); |
|
685 } |
|
686 iTestUtils.LogIt(KExpectedFields,aStringPool); |
|
687 iTestUtils.LogIt(KActualFields, aIniFile); |
|
688 |
|
689 } |
|
690 |
|
691 /** |
|
692 Compares the values provided for each header in the ini file with those obtained from |
|
693 the string pool |
|
694 @param headers |
|
695 Collection of headers from the response/request |
|
696 @param xyz |
|
697 Number of fields/headers present in the string pool |
|
698 @param xx |
|
699 Index value the header that needs to be processed |
|
700 @param headerStr |
|
701 Holds the header name that is obtained from the string pool |
|
702 @leave |
|
703 KErrArgument if the field values do not match |
|
704 */ |
|
705 void CPipeliningTestCase::FieldValueCompareL(RHTTPHeaders headers, TInt xyz, TInt xx, RStringF headerStr) |
|
706 { |
|
707 |
|
708 _LIT(KTxtFailed, "**TEST FAILED**"); |
|
709 _LIT(KExpectedValue, "Expected Value: %S"); |
|
710 _LIT(KActualValue, "Actual Value: %S"); |
|
711 |
|
712 TBuf<100> buf1, buf2; |
|
713 THTTPHdrVal hdrVal; |
|
714 |
|
715 for ( TInt mn =0; mn < xyz; ++mn) |
|
716 { |
|
717 User::LeaveIfError(headers.GetField(headerStr,mn,hdrVal)); |
|
718 TPtrC8 ptrValue1 ( hdrVal.StrF ().DesC() ); |
|
719 if (TInt mno = ptrValue1.Compare(iPipeliningTestParams.HeaderVal(xx+1,mn+1)) != 0) |
|
720 { |
|
721 buf1.Copy(ptrValue1); |
|
722 buf2.Copy(iPipeliningTestParams.HeaderVal(xx + 1,mn + 1)); |
|
723 iTestUtils.LogIt(KExpectedValue, &buf1); |
|
724 iTestUtils.LogIt(KActualValue, &buf2); |
|
725 iTestUtils.LogIt(KTxtFailed); |
|
726 User::Leave(KErrArgument); |
|
727 } |
|
728 buf1.Copy(ptrValue1); |
|
729 buf2.Copy(iPipeliningTestParams.HeaderVal(xx + 1,mn + 1)); |
|
730 iTestUtils.LogIt(KExpectedValue, &buf1); |
|
731 iTestUtils.LogIt(KActualValue, &buf2); |
|
732 } |
|
733 } |
|
734 |
|
735 |
|
736 |
|
737 |
|
738 |
|
739 |
|
740 |