|
1 /* |
|
2 * Copyright (c) 2007 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 the License "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 #ifndef MULTIPARTCONTENTHANDLER_H |
|
20 #define MULTIPARTCONTENTHANDLER_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <http/rhttptransaction.h> |
|
24 |
|
25 class CHttpCacheManager; |
|
26 class CBodyPart; |
|
27 namespace WebCore { |
|
28 class ResourceResponse; |
|
29 }; |
|
30 |
|
31 // CONSTANTS |
|
32 |
|
33 // the following are flags used to configure the multipart validity test |
|
34 // that is performed within function ValidateMultipartArray() |
|
35 // |
|
36 // test that base url of all parts match base url of multipart response |
|
37 const TInt KRulePartUrlMatchesRespUrl = 0x01; |
|
38 // test of URL includes scheme |
|
39 const TInt KRuleUrlMatchingOnScheme = 0x02; |
|
40 // test of URL includes hostname |
|
41 const TInt KRuleUrlMatchingOnHostname = 0x04; |
|
42 // test of URL includes port |
|
43 const TInt KRuleUrlMatchingOnPort = 0x08; |
|
44 // test that first part is a markup type (ie, HTML, XHTML, WML) |
|
45 const TInt KRuleFirstPartIsMarkup = 0x10; |
|
46 // test that parts are: markup, image, script, css or sound |
|
47 const TInt KRuleOnlyWebContentAllowed = 0x20; |
|
48 |
|
49 class MultipartContentHandler |
|
50 { |
|
51 public: // Constructors and destructor |
|
52 |
|
53 /** |
|
54 * Two-phased constructor. |
|
55 */ |
|
56 static MultipartContentHandler* NewL(); |
|
57 |
|
58 /** |
|
59 * Destructor. |
|
60 */ |
|
61 virtual ~MultipartContentHandler(); |
|
62 |
|
63 public: // New functions |
|
64 |
|
65 static bool IsSupported(const WebCore::ResourceResponse& response); |
|
66 |
|
67 TInt HandleResponseHeadersL(const WebCore::ResourceResponse& response, RHTTPTransaction& httpTransaction); |
|
68 |
|
69 TInt HandleResponseBodyL(TDesC8& aRespData); |
|
70 |
|
71 TInt ResponseComplete(); |
|
72 |
|
73 const TDesC8& MarkupContent(); |
|
74 TPtrC8& MarkupCharset() { return m_MarkupCharset; } |
|
75 TPtrC8& MarkupContentType() { return m_MarkupContentType; } |
|
76 |
|
77 private: |
|
78 |
|
79 /** |
|
80 * C++ default constructor. |
|
81 */ |
|
82 MultipartContentHandler(); |
|
83 |
|
84 /** |
|
85 * By default Symbian 2nd phase constructor is private. |
|
86 */ |
|
87 void ConstructL(); |
|
88 |
|
89 /** |
|
90 * |
|
91 * @since 3.0 |
|
92 * @param |
|
93 * @return |
|
94 */ |
|
95 TInt HandleMultipartMixedL(); |
|
96 |
|
97 /** |
|
98 * |
|
99 * @since 3.0 |
|
100 * @param |
|
101 * @return |
|
102 */ |
|
103 //void PushToMemoryCacheL(CBodyPart& aPart); |
|
104 |
|
105 /** |
|
106 * |
|
107 * @since 3.0 |
|
108 * @param |
|
109 * @return |
|
110 */ |
|
111 void PushToHttpCacheL(CBodyPart& aPart, CHttpCacheManager* aCacheMgr); |
|
112 |
|
113 /** |
|
114 * |
|
115 * @since 3.0 |
|
116 * @param |
|
117 * @return |
|
118 */ |
|
119 TInt ValidateMultipartArrayL(); |
|
120 |
|
121 /** |
|
122 * |
|
123 * @since 5.0 |
|
124 * @param |
|
125 * @return |
|
126 */ |
|
127 HBufC8* GenerateExpiresHeaderL(); |
|
128 |
|
129 /** |
|
130 * |
|
131 * @since 3.0 |
|
132 * @param |
|
133 * @return |
|
134 */ |
|
135 //TInt IsExtensionTypeText(const TDesC16& aResponseUrl); |
|
136 |
|
137 private: // Data |
|
138 // |
|
139 HBufC* m_ResponseUrl; // owned |
|
140 // multipart boundary string |
|
141 HBufC8* m_TopLevelBoundary; // owned |
|
142 // multipart boundary string with trailing "--" |
|
143 HBufC8* m_TopLevelBoundaryEnd; // owned |
|
144 // buffer to collect response body chunks until |
|
145 // response is complete |
|
146 HBufC8* m_ResponseBuffer; // owned |
|
147 // array of multipart body parts |
|
148 RPointerArray <CBodyPart> m_BodyPartsArray; |
|
149 // indicates if multipart content has been parsed |
|
150 bool m_ParsingCompleted; |
|
151 // descriptor containing the markup for the response |
|
152 // if response was not valid then this will contain the |
|
153 // error response content |
|
154 TPtrC8 m_MarkupContent; |
|
155 TPtrC8 m_MarkupCharset; |
|
156 TPtrC8 m_MarkupContentType; |
|
157 // |
|
158 HBufC8* m_CacheExpirationHeader; // owned |
|
159 }; |
|
160 |
|
161 #endif // MULTIPARTCONTENTHANDLER_H |
|
162 |
|
163 // End of File |