|
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 "CTestCase4.h" |
|
17 #include "httptestutils.h" |
|
18 |
|
19 const TInt KConn1TransCount = 5; |
|
20 const TInt KConnectionCount = 1; |
|
21 _LIT8(KTxtRawRequest, "GET / HTTP/1.1\r\nHost: 127.0.0.1\r\n\r\n"); |
|
22 _LIT8(KTxtRawRequestWithClose, "GET / HTTP/1.1\r\nConnection: Close\r\nHost: 127.0.0.1\r\n\r\n"); |
|
23 _LIT8(KTxtRawResponse, "HTTP/1.1 200 Ok\r\nContent-Length: 6\r\n\r\nhello!"); |
|
24 |
|
25 |
|
26 CTestCase4* CTestCase4::NewL(CHTTPTestUtils& aTestUtils) |
|
27 { |
|
28 CTestCase4* self = new (ELeave) CTestCase4(aTestUtils); |
|
29 CleanupStack::PushL(self); |
|
30 self->ConstructL(); |
|
31 CleanupStack::Pop(self); |
|
32 return self; |
|
33 } |
|
34 |
|
35 CTestCase4::CTestCase4(CHTTPTestUtils& aTestUtils) |
|
36 : CPipeliningTestCase(), iTestUtils(aTestUtils) |
|
37 { |
|
38 } |
|
39 |
|
40 void CTestCase4::ConstructL() |
|
41 { |
|
42 } |
|
43 |
|
44 CTestCase4::~CTestCase4() |
|
45 { |
|
46 } |
|
47 |
|
48 const TDesC& CTestCase4::TestCaseName() const |
|
49 { |
|
50 _LIT(KTxtTitle, "Test Case 4"); |
|
51 return KTxtTitle(); |
|
52 } |
|
53 |
|
54 TInt CTestCase4::TransactionCount(TInt aConnectionIndex) const |
|
55 { |
|
56 TInt transCount = 0; |
|
57 switch(aConnectionIndex) |
|
58 { |
|
59 case 0: |
|
60 { |
|
61 transCount = KConn1TransCount; |
|
62 } break; |
|
63 default: |
|
64 User::Invariant(); |
|
65 } |
|
66 |
|
67 return transCount; |
|
68 } |
|
69 |
|
70 TInt CTestCase4::TotalTransactionCount() const |
|
71 { |
|
72 return KConn1TransCount; |
|
73 } |
|
74 |
|
75 TInt CTestCase4::ConnectionCount() const |
|
76 { |
|
77 return KConnectionCount; |
|
78 } |
|
79 |
|
80 RHTTPTransaction CTestCase4::GetTransactionL(TInt aIndex, RHTTPSession aSession, MHTTPTransactionCallback& aClient) |
|
81 { |
|
82 __ASSERT_ALWAYS(aIndex<TotalTransactionCount(), User::Invariant()); |
|
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 |
|
89 if( aIndex==4 ) |
|
90 { |
|
91 RHTTPTransaction trans = aSession.OpenTransactionL(uri, aClient, method); |
|
92 AddConnectionCloseHeaderL(trans); |
|
93 return trans; |
|
94 } |
|
95 |
|
96 return aSession.OpenTransactionL(uri, aClient, method); |
|
97 } |
|
98 |
|
99 const TDesC8& CTestCase4::GetRawRequest(TInt aConnectionIndex, TInt aTransIndex) |
|
100 { |
|
101 __ASSERT_ALWAYS(aTransIndex<TransactionCount(aConnectionIndex), User::Invariant()); |
|
102 |
|
103 if( aConnectionIndex==0 && aTransIndex==4 ) |
|
104 return KTxtRawRequestWithClose(); |
|
105 |
|
106 return KTxtRawRequest(); |
|
107 } |
|
108 |
|
109 const TDesC8& CTestCase4::GetRawResponse(TInt aConnectionIndex, TInt aTransIndex) |
|
110 { |
|
111 __ASSERT_ALWAYS(aTransIndex<TransactionCount(aConnectionIndex), User::Invariant()); |
|
112 |
|
113 return KTxtRawResponse(); |
|
114 } |
|
115 |
|
116 void CTestCase4::AddConnectionCloseHeaderL(RHTTPTransaction aTransaction) |
|
117 { |
|
118 RStringF name = aTransaction.Session().StringPool().StringF(HTTP::EConnection, RHTTPSession::GetTable()); |
|
119 THTTPHdrVal value = aTransaction.Session().StringPool().StringF(HTTP::EClose, RHTTPSession::GetTable()); |
|
120 |
|
121 aTransaction.Request().GetHeaderCollection().SetFieldL(name, value); |
|
122 } |
|
123 |