|
1 // Copyright (c) 2008-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 /** |
|
17 @file |
|
18 @internalComponent |
|
19 */ |
|
20 |
|
21 #ifndef __OCSPHTTPFILTER_H__ |
|
22 #define __OCSPHTTPFILTER_H__ |
|
23 |
|
24 #include <http/mhttpfilter.h> |
|
25 #include <http/rhttpsession.h> |
|
26 #include <http/cecomfilter.h> |
|
27 #include <http.h> |
|
28 |
|
29 // Forward declarations |
|
30 class TCustomDataSupplier; |
|
31 |
|
32 /** |
|
33 * An http filter which logs the requests sent to the responder |
|
34 * @see MHTTPFilter |
|
35 */ |
|
36 class COCSPHTTPFilter : public CEComFilter, public MHTTPFilter |
|
37 { |
|
38 public: |
|
39 /** Installs the user-agent filter |
|
40 @param aSession the session to install the filter into. |
|
41 @return Pointer to the newly installed plugin |
|
42 */ |
|
43 static CEComFilter* InstallFilterL(TAny* aSession); |
|
44 ~COCSPHTTPFilter(); |
|
45 |
|
46 // Methods from MHTTPFilterBase |
|
47 virtual void MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent); |
|
48 virtual TInt MHFRunError(TInt aError, RHTTPTransaction aTransaction, |
|
49 const THTTPEvent& aEvent); |
|
50 |
|
51 // Methods from MHTTPFilter |
|
52 virtual void MHFUnload(RHTTPSession aSession, THTTPFilterHandle aHandle); |
|
53 virtual void MHFLoad(RHTTPSession aSession, THTTPFilterHandle aHandle); |
|
54 |
|
55 protected: |
|
56 COCSPHTTPFilter(); |
|
57 void ConstructL(const RHTTPSession& aSession); |
|
58 |
|
59 // Log the transaction |
|
60 void LogTransactionStartL(const RHTTPTransaction& aTransaction); |
|
61 void LogTransactionEndL(const RHTTPTransaction& aTransaction); |
|
62 |
|
63 // Read test parameters using Publish & Subscribe method |
|
64 void ReadTestParameters(TInt& aNumDelayResp, TInt& aCountDropResp, |
|
65 TInt& aCountCorruptHTTPDataHeader, TInt& aCountCorruptHTTPDataBodySizeLarge, TInt& aCountCorruptHTTPDataBodySizeSmall, |
|
66 TInt& aCountCorruptOCSPData, |
|
67 TInt& aCountInternalErrorResp, TInt& aCountTryLaterResp, |
|
68 TInt& aCountSigValidateFailure); |
|
69 |
|
70 // To maintain persistence between retry attempts store the updated counts back |
|
71 void WriteTestParameters(TInt aCountDropResp, |
|
72 TInt aCountCorruptHTTPDataHeader, TInt aCountCorruptHTTPDataBodySizeLarge, TInt aCountCorruptHTTPDataBodySizeSmall, |
|
73 TInt aCountCorruptOCSPData, |
|
74 TInt aCountInternalErrorResp, TInt aCountTryLaterResp, |
|
75 TInt aCountSigValidateFailure); |
|
76 |
|
77 protected: |
|
78 RStringF iFilterName; // name of this filter (appears in filter lists) |
|
79 TInt iLoadCount; // reference count - unloads filter when reaches 0 |
|
80 RStringPool iStringPool; // for the filter name |
|
81 RFs iFs; |
|
82 RFile iLogFile; |
|
83 TBool iLogLineCompleted; // To prevent double logging of end time |
|
84 TBool iDataSupplied; |
|
85 |
|
86 // HTTP custom data supplier for returning canned responses |
|
87 TCustomDataSupplier* iCustomDataSupplier; |
|
88 }; |
|
89 |
|
90 /** |
|
91 * Custom HTTP body data supplier to send back canned responses |
|
92 * @see MHTTPDataSupplier |
|
93 */ |
|
94 class TCustomDataSupplier : public MHTTPDataSupplier |
|
95 { |
|
96 public: |
|
97 TCustomDataSupplier(TPtrC8& aData, RHTTPTransaction& aTransaction); |
|
98 |
|
99 public: |
|
100 // Methods from MHTTPDataSupplier |
|
101 TBool GetNextDataPart(TPtrC8& aDataPart); |
|
102 void ReleaseData(); |
|
103 TInt OverallDataSize(); |
|
104 TInt Reset(); |
|
105 |
|
106 private: |
|
107 TBool iDataSupplied; |
|
108 RHTTPTransaction* iTransaction; |
|
109 MHTTPDataSupplier* iOriginalSupplier; |
|
110 TPtrC8 iData; |
|
111 RBuf8 iCorruptData; |
|
112 }; |
|
113 |
|
114 #endif //__OCSPHTTPFILTER_H__ |
|
115 |