|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "ctestcasepipelinefallback.h" |
|
20 #include "httptestutils.h" |
|
21 |
|
22 const TInt KTransactionCount = 30; // Submit 30 transactions |
|
23 const TInt KConnectionCount = 1; |
|
24 const TInt KBufferSize = 70; // Batching buffer size in bytes of 2 requests. |
|
25 _LIT8(KTxtRawRequest, "GET / HTTP/1.1\r\nHost: 127.0.0.1\r\n\r\n"); |
|
26 _LIT8(KTxtRawResponse, "HTTP/1.1 200 Ok\r\nContent-Length: 6\r\n\r\nhello!"); |
|
27 |
|
28 CTestCasePipelineFallback* CTestCasePipelineFallback::NewL(CHTTPTestUtils& aTestUtils) |
|
29 { |
|
30 CTestCasePipelineFallback* self = new (ELeave) CTestCasePipelineFallback(aTestUtils); |
|
31 CleanupStack::PushL(self); |
|
32 self->ConstructL(); |
|
33 CleanupStack::Pop(self); |
|
34 return self; |
|
35 } |
|
36 |
|
37 CTestCasePipelineFallback::CTestCasePipelineFallback(CHTTPTestUtils& aTestUtils) |
|
38 : CBatchingTestCase(), iTestUtils(aTestUtils) |
|
39 { |
|
40 } |
|
41 |
|
42 void CTestCasePipelineFallback::ConstructL() |
|
43 { |
|
44 } |
|
45 |
|
46 CTestCasePipelineFallback::~CTestCasePipelineFallback() |
|
47 { |
|
48 } |
|
49 |
|
50 const TDesC& CTestCasePipelineFallback::TestCaseName() const |
|
51 { |
|
52 _LIT(KTxtTitle, "Test Case Pipeline Fallback"); |
|
53 return KTxtTitle(); |
|
54 } |
|
55 |
|
56 TInt CTestCasePipelineFallback::TotalTransactionCount() const |
|
57 { |
|
58 return KTransactionCount; |
|
59 } |
|
60 |
|
61 TInt CTestCasePipelineFallback::ConnectionCount() const |
|
62 { |
|
63 return KConnectionCount; |
|
64 } |
|
65 |
|
66 RHTTPTransaction CTestCasePipelineFallback::GetTransactionL(TInt aIndex, RHTTPSession aSession, MHTTPTransactionCallback& aClient) |
|
67 { |
|
68 __ASSERT_ALWAYS(aIndex<KTransactionCount, User::Invariant()); |
|
69 |
|
70 // Buffer size needs to be reduced in the session property before the first transaction. |
|
71 if( aIndex == 0 ) |
|
72 { |
|
73 RHTTPConnectionInfo connInfo = aSession.ConnectionInfo(); |
|
74 // Set the batching buffer size |
|
75 connInfo.SetPropertyL(aSession.StringPool().StringF(HTTP::EBatchingBufferSize,RHTTPSession::GetTable()), KBufferSize); |
|
76 |
|
77 // Set optimal pipelining |
|
78 RStringF strOptimalPipelineVal = aSession.StringPool().StringF(HTTP::EHttpEnableOptimalPipelining, RHTTPSession::GetTable()); |
|
79 connInfo.SetPropertyL(aSession.StringPool().StringF(HTTP::EHttpOptimalPipelining, RHTTPSession::GetTable()), strOptimalPipelineVal); |
|
80 connInfo.SetPropertyL(aSession.StringPool().StringF(HTTP::EMaxNumTransportHandlers, RHTTPSession::GetTable()), 1); |
|
81 connInfo.SetPropertyL(aSession.StringPool().StringF(HTTP::EMaxNumTransactionsToPipeline, RHTTPSession::GetTable()), 5); |
|
82 } |
|
83 |
|
84 RStringF method = aSession.StringPool().StringF(HTTP::EGET,RHTTPSession::GetTable()); |
|
85 _LIT8(KTxtUri, "http://127.0.0.1"); |
|
86 TUriParser8 uri; |
|
87 uri.Parse(KTxtUri()); |
|
88 return aSession.OpenTransactionL(uri, aClient, method); |
|
89 } |
|
90 |
|
91 const TDesC8& CTestCasePipelineFallback::GetRawRequest(TInt /*aConnectionIndex*/, TInt /*aTransIndex*/) |
|
92 { |
|
93 // __ASSERT_ALWAYS( (aTransIndex<KTransactionCount), User::Invariant()); |
|
94 |
|
95 return KTxtRawRequest(); |
|
96 } |
|
97 |
|
98 const TDesC8& CTestCasePipelineFallback::GetRawResponse(TInt /*aConnectionIndex*/, TInt /*aTransIndex*/) |
|
99 { |
|
100 // __ASSERT_ALWAYS( (aTransIndex<KTransactionCount), User::Invariant()); |
|
101 |
|
102 return KTxtRawResponse(); |
|
103 } |
|
104 |
|
105 void CTestCasePipelineFallback::IncFallingBack() |
|
106 { |
|
107 ++iFallingback; |
|
108 } |
|
109 |
|
110 TBool CTestCasePipelineFallback::FallingBack() const |
|
111 { |
|
112 return (iFallingback == 2); // Max connection failure is 2 |
|
113 } |
|
114 |
|
115 |
|
116 |