|
1 // Copyright (c) 2001-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 __CWSPHEADERREADER_H__ |
|
17 #define __CWSPHEADERREADER_H__ |
|
18 |
|
19 // System Includes |
|
20 #include <e32std.h> |
|
21 #include <wspdecoder.h> |
|
22 #include <http/framework/cheadercodec.h> |
|
23 |
|
24 // User Includes |
|
25 #include "cwspheadercodec.h" |
|
26 |
|
27 // Forward declarations |
|
28 class CHeaderFieldPart; |
|
29 class CHeaderFieldParam; |
|
30 |
|
31 |
|
32 /** |
|
33 @internalAll |
|
34 @since 7.0 |
|
35 This class is the by the WSP header codec to provide the decoding functionality required |
|
36 by WSP to decode header fields from a raw binary format to a useful parsed format. The |
|
37 decoding is done as stated in the WSP specifications avaialable from www.wapforum.org. |
|
38 */ |
|
39 //##ModelId=3C4C41AB029F |
|
40 class CWspHeaderReader : public CHeaderReader |
|
41 { |
|
42 public: // methods |
|
43 |
|
44 /** |
|
45 Standard virtual destructor. |
|
46 @since 7.0 |
|
47 @pre Object is constructed |
|
48 @post Object is destroyed |
|
49 */ |
|
50 //##ModelId=3C4C41AC0108 |
|
51 virtual ~CWspHeaderReader(); |
|
52 |
|
53 /** |
|
54 Standard factory 2 phase construction. |
|
55 Error Condition: Low memory conditions |
|
56 @since 7.0 |
|
57 @param aStrPool A handle to an opened string pool with the WSP table opened |
|
58 @param aStrTable The WSP table that contains the header field names |
|
59 @param aCodec A reference to the parent owning codec |
|
60 @return A pointer to the newly created object |
|
61 @pre None |
|
62 @post Object is fully constructed |
|
63 @leave KErrNoMemory |
|
64 */ |
|
65 //##ModelId=3C4C41AC00FD |
|
66 static CWspHeaderReader* NewL(RStringPool aStrPool, const TStringTable& aStrTable, CWspHeaderCodec& aCodec); |
|
67 |
|
68 /** |
|
69 Standard factory 2 phase construction leaving a handle on the cleanup stack. |
|
70 Error Condition: Low memory conditions |
|
71 @since 7.0 |
|
72 @param aStrPool A handle to an opened string pool with the WSP table opened |
|
73 @param aStrTable The WSP table that contains the header field names |
|
74 @param aCodec A reference to the parent owning codec |
|
75 @return A pointer to the newly created object |
|
76 @pre None |
|
77 @post Object is fully constructed with a handle on the cleanup stack |
|
78 @leave KErrNoMemory |
|
79 */ |
|
80 //##ModelId=3C4C41AC00F3 |
|
81 static CWspHeaderReader* NewLC(RStringPool aStrPool, const TStringTable& aStrTable, CWspHeaderCodec& aCodec); |
|
82 |
|
83 /** |
|
84 This method is used by the codec to decode any supported header field that |
|
85 passed in. |
|
86 Error Condition: Low memory conditions or invalid or corrupt data |
|
87 @since 7.0 |
|
88 @param aHeader A reference to the header field to decode |
|
89 @pre The header field is its raw format state |
|
90 @post The header field is decoded and in its parsed state |
|
91 @leave KErrNoMemory |
|
92 KErrNotSupported if the header field is not supported |
|
93 KErrCorrupt if the data is invalid or corrupt |
|
94 */ |
|
95 //##ModelId=3C4C41AC00EA |
|
96 virtual void DecodeHeaderL(RHeaderField& aHeader); |
|
97 |
|
98 protected: // methods |
|
99 |
|
100 /** |
|
101 Standard default constructor. |
|
102 Error Condition: Low memory conditions |
|
103 @since 7.0 |
|
104 @param aStrPool A handle to an opened string pool with the WSP table opened |
|
105 @param aStrTable The WSP table that contains the header field names |
|
106 @param aCodec A reference to the parent owning codec |
|
107 @pre None |
|
108 @post Object is constructed |
|
109 */ |
|
110 //##ModelId=3C4C41AC00DF |
|
111 CWspHeaderReader(RStringPool aStrPool, const TStringTable& aStrTable, CWspHeaderCodec& aCodec); |
|
112 |
|
113 private: // methods |
|
114 |
|
115 /** Decodes the Content-type header field |
|
116 */ |
|
117 //##ModelId=3C4C41AC00D6RS |
|
118 void DecodeContentTypeL(RHeaderField& aHeader) const; |
|
119 |
|
120 /** Decodes the Date header field |
|
121 */ |
|
122 //##ModelId=3C4C41AC00D4 |
|
123 void DecodeDateL(RHeaderField& aHeader) const; |
|
124 |
|
125 /** Decodes the Last-modified header field |
|
126 */ |
|
127 //##ModelId=3C4C41AC00CC |
|
128 void DecodeLastModifiedL(RHeaderField& aHeader) const; |
|
129 |
|
130 /** Decodes the Pragma header field |
|
131 */ |
|
132 //##ModelId=3C4C41AC00CA |
|
133 void DecodePragmaL(RHeaderField& aHeader) const; |
|
134 |
|
135 /** Decodes the Vary header field |
|
136 */ |
|
137 //##ModelId=3C4C41AC00C1 |
|
138 void DecodeVaryL(RHeaderField& aHeader) const; |
|
139 |
|
140 /** Decodes the WWW-Authenticate header field |
|
141 */ |
|
142 //##ModelId=3C4C41AC00B8 |
|
143 void DecodeWWWAuthenticateL(RHeaderField& aHeader) const; |
|
144 |
|
145 /** Decodes the Set-Cookie header field |
|
146 */ |
|
147 //##ModelId=3C4C41AC00B6 |
|
148 void DecodeSetCookieL(RHeaderField& aHeader) const; |
|
149 |
|
150 /** Decodes the Content-location header field |
|
151 */ |
|
152 //##ModelId=3C4C41AC00AC |
|
153 void DecodeContentLocationL(RHeaderField& aHeader) const; |
|
154 |
|
155 /** Decodes the Location header field |
|
156 */ |
|
157 //##ModelId=3C4C41AC00A4 |
|
158 void DecodeLocationL(RHeaderField& aHeader) const; |
|
159 |
|
160 /** Decodes the Encoding-version header field |
|
161 */ |
|
162 //##ModelId=3C4C41AC00A2 |
|
163 void DecodeEncodingVersionL(RHeaderField& aHeader) const; |
|
164 |
|
165 /** Decodes the Accept-ranges header field |
|
166 */ |
|
167 //##ModelId=3C4C41AC0099 |
|
168 void DecodeAcceptRangesL(RHeaderField& aHeader) const; |
|
169 |
|
170 /** Decodes the Content-encoding header field |
|
171 */ |
|
172 //##ModelId=3C4C41AC0090 |
|
173 void DecodeContentEncodingL(RHeaderField& aHeader) const; |
|
174 |
|
175 /** Decodes the Content-language header field |
|
176 */ |
|
177 //##ModelId=3C4C41AC008E |
|
178 void DecodeContentLanguageL(RHeaderField& aHeader) const; |
|
179 |
|
180 /** Decodes the Content-MD5 header field |
|
181 */ |
|
182 //##ModelId=3C4C41AC0085 |
|
183 void DecodeContentMD5L(RHeaderField& aHeader) const; |
|
184 |
|
185 /** Decodes the Proxy-authenticate header field |
|
186 */ |
|
187 //##ModelId=3C4C41AC007C |
|
188 void DecodeProxyAuthenticateL(RHeaderField& aHeader) const; |
|
189 |
|
190 /** Decodes the Server header field |
|
191 */ |
|
192 //##ModelId=3C4C41AC007A |
|
193 void DecodeServerL(RHeaderField& aHeader) const; |
|
194 |
|
195 /** Decodes the Retry-after header field |
|
196 */ |
|
197 //##ModelId=3C4C41AC0071 |
|
198 void DecodeRetryAfterL(RHeaderField& aHeader) const; |
|
199 |
|
200 /** Decodes the Via header field |
|
201 */ |
|
202 //##ModelId=3C4C41AC0068 |
|
203 void DecodeViaL(RHeaderField& aHeader) const; |
|
204 |
|
205 /** Decodes the Trailer header field |
|
206 */ |
|
207 //##ModelId=3C4C41AC0066 |
|
208 void DecodeTrailerL(RHeaderField& aHeader) const; |
|
209 |
|
210 /** Decodes the Content-range header field |
|
211 */ |
|
212 //##ModelId=3C4C41AC005E |
|
213 void DecodeContentRangeL(RHeaderField& aHeader) const; |
|
214 |
|
215 /** Decodes the X-Wap-Application-Id header field |
|
216 */ |
|
217 //##ModelId=3C4C41AC005C |
|
218 void DecodeXWapApplicationIdL(RHeaderField& aHeader) const; |
|
219 |
|
220 /** Decodes the X-Wap-Initiator-URI header field |
|
221 */ |
|
222 //##ModelId=3C4C41AC0053 |
|
223 void DecodeXWapInitiatorURIL(RHeaderField& aHeader) const; |
|
224 |
|
225 /** Decodes the Push-flag header field |
|
226 */ |
|
227 //##ModelId=3C4C41AC0049 |
|
228 void DecodePushFlagL(RHeaderField& aHeader) const; |
|
229 |
|
230 /** Decodes the Allow header field |
|
231 */ |
|
232 //##ModelId=3C4C41AC0040 |
|
233 void DecodeAllowL(RHeaderField& aHeader) const; |
|
234 |
|
235 /** Decodes the Upgrade header field |
|
236 */ |
|
237 //##ModelId=3C4C41AC003E |
|
238 void DecodeUpgradeL(RHeaderField& aHeader) const; |
|
239 |
|
240 /** Decodes the Warning header field |
|
241 */ |
|
242 //##ModelId=3C4C41AC0035 |
|
243 void DecodeWarningL(RHeaderField& aHeader) const; |
|
244 |
|
245 /** Decodes the Profile-Warning header field |
|
246 */ |
|
247 void DecodeProfileWarningL(RHeaderField& aHeader) const; |
|
248 |
|
249 // utility helper methods |
|
250 |
|
251 /** Decodes the warn codes |
|
252 */ |
|
253 //##ModelId=3C4C41AC002C |
|
254 void DecodeGenericWarnCodeL(RHeaderField& aHeader, TWspPrimitiveDecoder& aDecoder) const; |
|
255 |
|
256 /** Checks for NULL strings, ie strings with no but data with a NULL terminator |
|
257 */ |
|
258 //##ModelId=3C4C41AB03CE |
|
259 TBool CheckForNullStringL(TPtrC8& aRawData, TInt& aBytesRead, TWspPrimitiveDecoder& aDecoder) const; |
|
260 |
|
261 /** Decodes version values |
|
262 */ |
|
263 //##ModelId=3C4C41AB03C3 |
|
264 void DecodeGenericVersionL(RHeaderField& aHeader, TWspPrimitiveDecoder& aDecoder, TInt aIndex) const; |
|
265 |
|
266 /** Check the length of data is greater than a required minimum |
|
267 */ |
|
268 //##ModelId=3C4C41AB03B9 |
|
269 inline void CheckLengthL(TPtrC8& aRawData, TInt aMinLength) const; |
|
270 |
|
271 /** Check for a NULL data part and adds a NULL descriptor part to the parsed data |
|
272 */ |
|
273 //##ModelId=3C4C41AB03AE |
|
274 TBool CheckNullDesPartL(RHeaderField& aHeader, TPtrC8& aRawData, TInt aPartIndex) const; |
|
275 |
|
276 /** Adds a new string part to the parsed data |
|
277 */ |
|
278 //##ModelId=3C4C41AB039C |
|
279 TInt AddNewDecoderStringPartL(RHeaderField& aHeader, TWspPrimitiveDecoder& aDecoder, TInt aIndex=0) const; |
|
280 |
|
281 // generic encoding methods |
|
282 |
|
283 /** Decodes generic integer values |
|
284 */ |
|
285 //##ModelId=3C4C41AB039A |
|
286 void DecodeGenericIntegerValueL(RHeaderField& aHeader) const; |
|
287 |
|
288 /** Decodes generic new string values |
|
289 */ |
|
290 //##ModelId=3C4C41AB0390 |
|
291 void DecodeGenericNewStringValueL(RHeaderField& aHeader) const; |
|
292 |
|
293 /** Decodes generic data values |
|
294 */ |
|
295 //##ModelId=3C4C41AB0387 |
|
296 void DecodeGenericDateValueL(RHeaderField& aHeader) const; |
|
297 |
|
298 /** Decodes generic field names |
|
299 */ |
|
300 //##ModelId=3C4C41AB037E |
|
301 void DecodeGenericFieldNameL(RHeaderField& aHeader) const; |
|
302 |
|
303 /** Decodes generic string parameter types |
|
304 */ |
|
305 //##ModelId=3C4C41AB0374 |
|
306 TInt DecodeGenericSingleParameterL(TPtrC8& aRawParam, CHeaderFieldPart& aHeaderFieldPart) const; |
|
307 |
|
308 /** Decodes well known parameter tokens |
|
309 */ |
|
310 //##ModelId=3C4C41AB0368 |
|
311 void DecodeWellKnownParamTokenL(TWspPrimitiveDecoder& aDecoder, TInt& aBytesRead, |
|
312 TPtrC8& aRawParamBlock, CHeaderFieldPart& aHeaderFieldPart) const; |
|
313 |
|
314 /** Decodes untyped parameter types |
|
315 */ |
|
316 //##ModelId=3C4C41AB0355 |
|
317 void DecodeUntypedParamL(TWspPrimitiveDecoder& aDecoder, TInt& aBytesRead, |
|
318 TPtrC8& aRawParamBlock, CHeaderFieldPart& aHeaderFieldPart) const; |
|
319 |
|
320 /** Decodes generic parameter tokens |
|
321 */ |
|
322 //##ModelId=3C4C41AB034A |
|
323 TInt DecodeGenericParamTokenL(TWspPrimitiveDecoder& aDecoder, const TStringTable& aStrTable, |
|
324 THTTPHdrVal& aParamValue, RStringF& aParamDesValue) const; |
|
325 |
|
326 /** Decodes character-sets |
|
327 */ |
|
328 //##ModelId=3C4C41AB033F |
|
329 void GetCharacterSetFromValueL(TInt aValue, RStringF& aCharSetStr) const; |
|
330 |
|
331 /** Decodes generic challenge data |
|
332 */ |
|
333 //##ModelId=3C4C41AB0335 |
|
334 void DecodeGenericChallengeL(RHeaderField& aHeader) const; |
|
335 |
|
336 // generic part methods |
|
337 |
|
338 /** Sets a new part |
|
339 */ |
|
340 //##ModelId=3C4C41AB032B |
|
341 CHeaderFieldPart& SetNewPartL(RHeaderField& aHeader, TInt aPartIndex, THTTPHdrVal& aPartVal) const; |
|
342 |
|
343 /** Sets a new integer part |
|
344 */ |
|
345 //##ModelId=3C4C41AB0318 |
|
346 CHeaderFieldPart& SetNewIntegerPartL(RHeaderField& aHeader, TInt aPartIndex, TInt aValue) const; |
|
347 |
|
348 /** Sets a new case insensitive string part |
|
349 */ |
|
350 //##ModelId=3C4C41AB030D |
|
351 CHeaderFieldPart& SetNewFStringPartL(RHeaderField& aHeader, TInt aPartIndex, TPtrC8 aValue) const; |
|
352 |
|
353 /** Sets a new case sensitive string part |
|
354 */ |
|
355 //##ModelId=3C4C41AB02FB |
|
356 CHeaderFieldPart& SetNewStringPartL(RHeaderField& aHeader, TInt aPartIndex, TPtrC8 aValue) const; |
|
357 |
|
358 /** Sets an existing case insensitive string part |
|
359 */ |
|
360 //##ModelId=3C4C41AB02F0 |
|
361 CHeaderFieldPart& SetFStringPartL(RHeaderField& aHeader, TInt aPartIndex, RStringF aStrVal) const; |
|
362 |
|
363 /** Sets a new date value part |
|
364 */ |
|
365 //##ModelId=3C4C41AB02E5 |
|
366 CHeaderFieldPart& SetNewDatePartL(RHeaderField& aHeader, TInt aPartIndex, TDateTime& aValue) const; |
|
367 |
|
368 /** Adds a new param to the supplied part |
|
369 */ |
|
370 //##ModelId=3C4C41AB02D1 |
|
371 CHeaderFieldParam& SetNewParamL(CHeaderFieldPart& aHeaderPart, TPtrC8 aParamName, THTTPHdrVal aParamValue) const; |
|
372 |
|
373 private: // attributes |
|
374 |
|
375 /** Handle to an opened string pool with the WSP header field names table opened |
|
376 */ |
|
377 //##ModelId=3C4C41AB02C9 |
|
378 RStringPool iStrPool; |
|
379 |
|
380 /** Reference to the WSP header field names table |
|
381 */ |
|
382 //##ModelId=3C4C41AB02BF |
|
383 const TStringTable& iStrTable; |
|
384 |
|
385 /** Reference to the parent owning codec |
|
386 */ |
|
387 //##ModelId=3C4C41AB02B3 |
|
388 CWspHeaderCodec& iCodec; |
|
389 }; |
|
390 |
|
391 inline void CWspHeaderReader::CheckLengthL(TPtrC8& aRawData, TInt aMinLength) const |
|
392 { |
|
393 if(aRawData.Length() < aMinLength) |
|
394 User::Leave(KErrCorrupt); |
|
395 } |
|
396 |
|
397 /** |
|
398 @internalAll |
|
399 @since 7.0 |
|
400 This class is the by the WSP header codec to provide the decoding functionality required |
|
401 by WSP to decode header fields from a raw binary format to a useful parsed format. This |
|
402 decoder is the default decoder for headers that have no specific decoding pattern and |
|
403 expects text-string format data as defined WSP specifications avaialable from www.wapforum.org. |
|
404 */ |
|
405 class CWspDefaultHdrReader : public CHeaderReader |
|
406 { |
|
407 public: // methods |
|
408 |
|
409 /** |
|
410 Standard virtual destructor. |
|
411 @since 7.0 |
|
412 @pre Object is constructed |
|
413 @post Object is destroyed |
|
414 */ |
|
415 //##ModelId=3C4C41AC0108 |
|
416 virtual ~CWspDefaultHdrReader(); |
|
417 |
|
418 /** |
|
419 Standard factory 2 phase construction. |
|
420 Error Condition: Low memory conditions |
|
421 @since 7.0 |
|
422 @param aStrPool A handle to an opened string pool |
|
423 @return A pointer to the newly created object |
|
424 @pre None |
|
425 @post Object is fully constructed |
|
426 @leave KErrNoMemory |
|
427 */ |
|
428 static CWspDefaultHdrReader* NewL(RStringPool aStrPool); |
|
429 |
|
430 /** |
|
431 Standard factory 2 phase construction leaving a handle on the cleanup stack. |
|
432 Error Condition: Low memory conditions |
|
433 @since 7.0 |
|
434 @param aStrPool A handle to an opened string pool |
|
435 @return A pointer to the newly created object |
|
436 @pre None |
|
437 @post Object is fully constructed with a handle on the cleanup stack |
|
438 @leave KErrNoMemory |
|
439 */ |
|
440 static CWspDefaultHdrReader* NewLC(RStringPool aStrPool); |
|
441 |
|
442 /** |
|
443 This method is used by the codec to decode any header field that is |
|
444 passed in. Assumes the header field value is a text-string. |
|
445 Error Condition: Low memory conditions or invalid or corrupt data |
|
446 @since 7.0 |
|
447 @param aHeader A reference to the header field to decode |
|
448 @pre The header field is its raw format state |
|
449 @post The header field is decoded and in its parsed state |
|
450 @leave KErrNoMemory |
|
451 KErrNotSupported if the header field is not supported |
|
452 KErrCorrupt if the data is invalid or corrupt |
|
453 */ |
|
454 virtual void DecodeHeaderL(RHeaderField& aHeader); |
|
455 |
|
456 protected: // methods |
|
457 |
|
458 /** |
|
459 Standard default constructor. |
|
460 Error Condition: Low memory conditions |
|
461 @since 7.0 |
|
462 @param aStrPool A handle to an opened string pool |
|
463 @pre None |
|
464 @post Object is constructed |
|
465 */ |
|
466 //##ModelId=3C4C41AC00DF |
|
467 CWspDefaultHdrReader(RStringPool aStrPool); |
|
468 |
|
469 private: // attributes |
|
470 |
|
471 /** |
|
472 Handle to an opened string pool |
|
473 */ |
|
474 RStringPool iStrPool; |
|
475 }; |
|
476 |
|
477 #endif // __CWSPHEADERREADER_H__ |