|
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 "CTestCase14.h" |
|
17 #include "httptestutils.h" |
|
18 |
|
19 const TInt KTransactionCount = 3; |
|
20 const TInt KConnectionCount = 1; |
|
21 const TInt KBufferSize = 25; // Batching buffer size in bytes |
|
22 _LIT8(KTxtRawRequest1, "GET / HTTP/1.1\r\nHost: 127.0.0.1\r\n\r\n"); |
|
23 _LIT8(KTxtRawRequest2, "GET / HTTP/1.1\r\nHost: 127.0.0.1\r\nThis_Is_A_Long_Header_Name: This_Is_A_Long_Header_Value_abcdefghijklmnopqrstuvwxyz1234567890\r\n\r\n"); |
|
24 _LIT8(KTxtRawResponse, "HTTP/1.1 200 Ok\r\nContent-Length: 6\r\n\r\nhello!"); |
|
25 |
|
26 CTestCase14* CTestCase14::NewL(CHTTPTestUtils& aTestUtils) |
|
27 { |
|
28 CTestCase14* self = new (ELeave) CTestCase14(aTestUtils); |
|
29 CleanupStack::PushL(self); |
|
30 self->ConstructL(); |
|
31 CleanupStack::Pop(self); |
|
32 return self; |
|
33 } |
|
34 |
|
35 CTestCase14::CTestCase14(CHTTPTestUtils& aTestUtils) |
|
36 : CBatchingTestCase(), iTestUtils(aTestUtils) |
|
37 { |
|
38 } |
|
39 |
|
40 void CTestCase14::ConstructL() |
|
41 { |
|
42 } |
|
43 |
|
44 CTestCase14::~CTestCase14() |
|
45 { |
|
46 } |
|
47 |
|
48 const TDesC& CTestCase14::TestCaseName() const |
|
49 { |
|
50 _LIT(KTxtTitle, "Test Case 14"); |
|
51 return KTxtTitle(); |
|
52 } |
|
53 |
|
54 TInt CTestCase14::TotalTransactionCount() const |
|
55 { |
|
56 return KTransactionCount; |
|
57 } |
|
58 |
|
59 TInt CTestCase14::ConnectionCount() const |
|
60 { |
|
61 return KConnectionCount; |
|
62 } |
|
63 |
|
64 RHTTPTransaction CTestCase14::GetTransactionL(TInt aIndex, RHTTPSession aSession, MHTTPTransactionCallback& aClient) |
|
65 { |
|
66 __ASSERT_ALWAYS(aIndex<KTransactionCount, User::Invariant()); |
|
67 |
|
68 RStringF method = aSession.StringPool().StringF(HTTP::EGET,RHTTPSession::GetTable()); |
|
69 _LIT8(KTxtUri, "http://127.0.0.1"); |
|
70 TUriParser8 uri; |
|
71 uri.Parse(KTxtUri()); |
|
72 |
|
73 // Buffer size needs to be reduced in the session property before the first transaction. |
|
74 if( aIndex == 0 ) |
|
75 { |
|
76 RHTTPConnectionInfo connInfo = aSession.ConnectionInfo(); |
|
77 connInfo.SetPropertyL(aSession.StringPool().StringF(HTTP::EBatchingBufferSize,RHTTPSession::GetTable()), KBufferSize); |
|
78 } |
|
79 |
|
80 // If this is the 2nd request add large amount of header data to make the request |
|
81 // larger than the buffer size |
|
82 if( aIndex == 1 ) |
|
83 { |
|
84 // Add a fairly large header |
|
85 RHTTPTransaction trans = aSession.OpenTransactionL(uri, aClient, method); |
|
86 RHTTPHeaders headers = trans.Request().GetHeaderCollection(); |
|
87 |
|
88 _LIT8(KTxtHeaderName, "This_Is_A_Long_Header_Name"); |
|
89 _LIT8(KTxtHeaderValue, "This_Is_A_Long_Header_Value_abcdefghijklmnopqrstuvwxyz1234567890"); |
|
90 RStringF headerStrName = aSession.StringPool().OpenFStringL(KTxtHeaderName()); |
|
91 CleanupClosePushL(headerStrName); |
|
92 RStringF headerStrValue = aSession.StringPool().OpenFStringL(KTxtHeaderValue()); |
|
93 CleanupClosePushL(headerStrValue); |
|
94 THTTPHdrVal headerValue(headerStrValue); |
|
95 headers.SetFieldL(headerStrName, headerValue); |
|
96 CleanupStack::PopAndDestroy(2, &headerStrName); |
|
97 |
|
98 return trans; |
|
99 } |
|
100 |
|
101 return aSession.OpenTransactionL(uri, aClient, method); |
|
102 } |
|
103 |
|
104 const TDesC8& CTestCase14::GetRawRequest(TInt aConnectionIndex, TInt aTransIndex) |
|
105 { |
|
106 __ASSERT_ALWAYS( (aTransIndex<KTransactionCount) && (aConnectionIndex < KConnectionCount), User::Invariant()); |
|
107 |
|
108 if( aTransIndex == 1 ) |
|
109 return KTxtRawRequest2(); |
|
110 |
|
111 return KTxtRawRequest1(); |
|
112 } |
|
113 |
|
114 const TDesC8& CTestCase14::GetRawResponse(TInt aConnectionIndex, TInt aTransIndex) |
|
115 { |
|
116 __ASSERT_ALWAYS( (aTransIndex<KTransactionCount) && (aConnectionIndex < KConnectionCount), User::Invariant()); |
|
117 |
|
118 return KTxtRawResponse(); |
|
119 } |