|
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 #ifndef __CHTTPCLIENTTESTPARAMS_H__ |
|
17 #define __CHTTPCLIENTTESTPARAMS_H__ |
|
18 |
|
19 #include <e32base.h> |
|
20 #include <f32file.h> |
|
21 class CTestStep; |
|
22 |
|
23 class CHeaderFieldParamInfo : public CBase |
|
24 { |
|
25 public: |
|
26 ~CHeaderFieldParamInfo() |
|
27 { |
|
28 delete iParamName; |
|
29 delete iParamValue; |
|
30 } |
|
31 |
|
32 HBufC8* iParamName; |
|
33 HBufC8* iParamValue; |
|
34 }; |
|
35 |
|
36 class CHeaderFieldInfo : public CBase |
|
37 { |
|
38 public: |
|
39 ~CHeaderFieldInfo() |
|
40 { |
|
41 delete iFieldValue; |
|
42 iFieldParamInfos.ResetAndDestroy(); |
|
43 } |
|
44 HBufC8* iFieldValue; |
|
45 RPointerArray<CHeaderFieldParamInfo> iFieldParamInfos; |
|
46 }; |
|
47 |
|
48 class CHeaderInfo : public CBase |
|
49 { |
|
50 |
|
51 public: |
|
52 ~CHeaderInfo() |
|
53 { |
|
54 delete iFieldName; |
|
55 iFieldInfos.ResetAndDestroy(); |
|
56 iParamInfos.ResetAndDestroy(); |
|
57 } |
|
58 |
|
59 HBufC8* iFieldName; |
|
60 RPointerArray<CHeaderFieldInfo> iFieldInfos; |
|
61 RPointerArray<CHeaderFieldParamInfo> iParamInfos; |
|
62 }; |
|
63 |
|
64 |
|
65 class CFileSender : public CBase |
|
66 { |
|
67 friend class CHttpClientTestParams; |
|
68 public: |
|
69 static CFileSender* NewL(const TDesC& aFileName); |
|
70 ~CFileSender(); |
|
71 const TDesC8& Read(); |
|
72 const TDesC8& Read(TInt aSize); |
|
73 TInt Size(); |
|
74 TBool MoreToRead() const; |
|
75 const TDesC& FileName() const; |
|
76 |
|
77 private: |
|
78 CFileSender(); |
|
79 void ConstructL(const TDesC& aFileName); |
|
80 private: |
|
81 RFs iFs; |
|
82 RFile iFile; |
|
83 RBuf8 iBuffer; |
|
84 TInt iFileSize; |
|
85 HBufC* iFileName; |
|
86 }; |
|
87 |
|
88 class CFileReceiver : public CBase |
|
89 { |
|
90 friend class CHttpClientTestParams; |
|
91 public: |
|
92 static CFileReceiver* NewL(const TDesC& aFileName); |
|
93 TInt Write(const TDesC8& aData); |
|
94 ~CFileReceiver(); |
|
95 RFile& File(); |
|
96 const TDesC& FileName() const; |
|
97 TInt Size() |
|
98 { |
|
99 TInt size; |
|
100 iFile.Size(size); |
|
101 return size; |
|
102 } |
|
103 private: |
|
104 void ConstructL(const TDesC& aFileName); |
|
105 private: |
|
106 RFs iFs; |
|
107 RFile iFile; |
|
108 HBufC* iFileName; |
|
109 }; |
|
110 |
|
111 class THttpHeaderValueVariant; |
|
112 |
|
113 class CHttpClientTestParams : public CBase |
|
114 { |
|
115 public: |
|
116 static CHttpClientTestParams* NewL(CTestStep& aTestCase); |
|
117 ~CHttpClientTestParams(); |
|
118 |
|
119 |
|
120 TInt StatusCode() const; |
|
121 const TDesC8& Method() const; |
|
122 const TDesC8& Uri() const; |
|
123 const TDesC8& RawRequest() const; |
|
124 const TDesC8& RawResponse() const; |
|
125 const TDesC8& ResponseBody() const; |
|
126 const RPointerArray<CHeaderInfo>& HeaderInfos() const |
|
127 { |
|
128 return iResponseHeaderInfos; |
|
129 } |
|
130 |
|
131 const RPointerArray<CHeaderInfo>& RequestHeaderInfos() const |
|
132 { |
|
133 return iRequestHeaderInfos; |
|
134 } |
|
135 |
|
136 TBool CheckVariantValue(const THttpHeaderValueVariant& aVariant, const TDesC8& aValueToMatch); |
|
137 CHeaderInfo* FindHeaderInfo(const TDesC8& aHeaderName); |
|
138 |
|
139 TBool IsFileSending() const; |
|
140 TBool IsPendingRead() const; |
|
141 const TDesC8& ReadFromFile(); |
|
142 TInt WriteToFile(const TDesC8& aData); |
|
143 |
|
144 RFile& SinkFile(); |
|
145 RFile& SourceFile(); |
|
146 TBool MatchFileContent(); |
|
147 TBool MatchPostFileContent(); |
|
148 TBool NeedDisconnection() const; |
|
149 TInt ExpectedError() const; |
|
150 TBool NoRetryOnDisconnect() const; |
|
151 TBool ResponseTimeoutEnable() const; |
|
152 TBool IsRedirecting() const; |
|
153 TBool TransferProgress() const; |
|
154 |
|
155 const TDesC8& RequestBody() const |
|
156 { |
|
157 if(iRequestBody) |
|
158 return *iRequestBody; |
|
159 return KNullDesC8(); |
|
160 } |
|
161 TInt SendingFileSize() |
|
162 { |
|
163 return iFileSender->Size(); |
|
164 } |
|
165 TInt ReceivingFileSize() |
|
166 { |
|
167 return iFileReceiver->Size(); |
|
168 } |
|
169 TBool ResponseDynamicAndStatic() |
|
170 { |
|
171 return iResponseDynamicAndStatic; |
|
172 } |
|
173 TBool OnlineTest() |
|
174 { |
|
175 return iOnlineTest; |
|
176 } |
|
177 |
|
178 const TDesC8& ProxyAddress() const |
|
179 { |
|
180 if(iProxyAddress) |
|
181 return *iProxyAddress; |
|
182 return KNullDesC8(); |
|
183 } |
|
184 private: |
|
185 void ConstructL(CTestStep& aTestCase); |
|
186 |
|
187 |
|
188 private: |
|
189 CFileSender* iFileSender; |
|
190 CFileReceiver* iFileReceiver; |
|
191 TBool iConnDisconnect; |
|
192 TInt iStatusCode; |
|
193 HBufC8* iMethod; |
|
194 HBufC8* iUri; |
|
195 HBufC8* iRawRequest; |
|
196 HBufC8* iRawResponse; |
|
197 HBufC8* iResponseBody; |
|
198 HBufC8* iRequestBody; |
|
199 TInt iExpectedError; |
|
200 TBool iNoRetryOnDisconnect; |
|
201 RPointerArray<CHeaderInfo> iResponseHeaderInfos; |
|
202 RPointerArray<CHeaderInfo> iRequestHeaderInfos; |
|
203 TBool iResponseDynamicAndStatic; |
|
204 TBool iOnlineTest; |
|
205 TBool iResponseTimeout; |
|
206 TBool iRedirection; |
|
207 TBool iNotifyTransferProgress; |
|
208 HBufC8* iProxyAddress; |
|
209 }; |
|
210 |
|
211 class CHttpClientTestParamArray : public CBase |
|
212 { |
|
213 public: |
|
214 CHttpClientTestParamArray(); |
|
215 ~CHttpClientTestParamArray(); |
|
216 void AddTestParams(CHttpClientTestParams* aParams); |
|
217 CHttpClientTestParams* MatchingParam(const TDesC8& aData); |
|
218 private: |
|
219 RPointerArray<CHttpClientTestParams> iTestParamArray; |
|
220 }; |
|
221 |
|
222 #endif // __CHTTPCLIENTTESTPARAMS_H__ |