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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
18 @warning : This file contains Rose Model ID comments - please do not delete
21 #ifndef __CHEADERCODEC_H__
22 #define __CHEADERCODEC_H__
26 #include <http/framework/rheaderfield.h>
28 // Forward declarations
33 //##ModelId=3C4C18850126
34 class CHeaderCodec : public CBase
36 An abstract HTTP header codec.
38 Each instance of a concrete subclass of CHeaderCodec is associated with, and owned
39 by, a specific CProtocolHandler. It provides on-demand encoding/decoding of
40 HTTP header data, between the generic format used by clients/filters to formulate
41 requests and interpret responses, and the raw format used by
42 the transport handlers (and origin servers/gateways/etc.)
44 The CHeaderCodec has an associated instance of a sub-class of each of
45 CHeaderReader and CHeaderWriter. It delegates the actual encoding and
46 decoding function to these instances.
48 Header codecs provide a mechanism for extensibility whereby if one codec can't
49 decode (or encode) a given header, it locates a codec that can, and then delegates
50 the task to that codec instead.
58 Intended Usage: Destructor - cleans up and releases resources to the system.
60 //##ModelId=3C4C18850194
61 IMPORT_C virtual ~CHeaderCodec();
64 Encode the supplied header field. This method uses the associated
65 concrete CHeaderWriter object to do a conversion of the field into
66 raw form from the generic internal representation.
68 @param aHeader (in) A proxy for the header field to be encoded
69 @leave KErrNotSupported if a codec that supports encoding this header
72 //##ModelId=3C4C1885018C
73 IMPORT_C void EncodeHeaderL(RHeaderField& aHeader) const;
76 Decode the supplied header field. This method uses the associated
77 concrete CHeaderReader object to do a conversion of the field into
78 the generic internal representation from the raw form.
80 @param aHeader (in) A proxy for the header field to be decoded
82 @leave KErrNotSupported if a codec that supports decoding this header
86 //##ModelId=3C4C1885018A
87 IMPORT_C void DecodeHeaderL(RHeaderField& aHeader) const;
90 Intended Usage: Concrete header codec classes must implement this method to
91 indicate to the framework whether their concrete CHeaderWriter is
92 capable of encoding the named header field.
93 @param aHeaderField (in) A proxy for the header field to be encoded
94 @return A flag indicating ETrue if the field can be encoded.
96 //##ModelId=3C4C18850181
97 virtual TBool CanEncode(RStringF aHeaderField) const = 0;
100 Intended Usage: Concrete header codec classes must implement this method to
101 indicate to the framework whether their concrete CHeaderReader is
102 capable of decoding the named header field.
103 @param aHeaderField (in) A proxy for the header field to be encoded
104 @return A flag indicating ETrue if the field can be decoded.
106 //##ModelId=3C4C18850178
107 virtual TBool CanDecode(RStringF aHeaderField) const = 0;
110 Intended Usage: Concrete header codecs must be implement this method if they wish to
111 delegate the encoding/decoding of particular header fields to a
113 This would be done if the codec doesn't have the ability itself to
114 do the encode/decode but can locate an alternative that does. This
115 function may leave with a Standard Symbian OS error code. eg. KErrNoMemory
117 The caller takes ownership of the returned codec.
118 @param aHeaderField (in) A proxy for the header field to be encoded
119 @return A pointer to the new CHeaderCodec, or NULL if one couldn't be found.
120 @leave KErrNoMemory, Not enough memory to create object.
122 //##ModelId=3C4C18850176
123 virtual CHeaderCodec* FindDelegateCodecL(RStringF aHeaderField) const = 0;
125 protected: // methods
130 //##ModelId=3A914DF20273
131 IMPORT_C CHeaderCodec();
134 Second phase construction in which any necessary allocation is done
135 Implementations of this interface may leave with standard erros like KErrNoMemory if there is
136 insufficient memory for allocation in the second phase.
138 //##ModelId=3C4C1885016E
139 IMPORT_C void ConstructL();
141 protected: // attributes
143 /** The owned header writer object that does actual encoding of header fields.
145 //##ModelId=3C4C18850164
146 CHeaderWriter* iWriter;
148 /** The owned header reader object that does actual decoding of header fields.
150 //##ModelId=3C4C1885015A
151 CHeaderReader* iReader;
156 Intended Usage: Reserve a slot in the v-table to preserve future BC
158 //##ModelId=3C4C1885016D
159 inline virtual void Reserved1();
162 Intended Usage: Reserve a slot in the v-table to preserve future BC
164 //##ModelId=3C4C1885016C
165 inline virtual void Reserved2();
167 private: // attributes
169 /** The most recently-obtained delegate codec
171 //##ModelId=3C4C18850150
172 mutable CHeaderCodec* iDelegateCodec;
176 //##ModelId=3C4C188601D1
177 class CHeaderWriter : public CBase
179 An abstract HTTP header encoder. CHeaderWriter provides an interface used by its
180 owning codec to do conversion of header data from the generic internal header
181 representation to the raw representation used for a particular protocol/transport.
182 Specific sub-classes of CHeaderWriter are associated with specific protocol handlers.
190 Intended Usage: Destructor - cleans up and release resources to the system.
192 //##ModelId=3C4C188601FC
193 IMPORT_C virtual ~CHeaderWriter();
196 Intended Usage: Encodes the supplied header field. This method does a conversion
197 of the field into raw form from the generic internal representation.
199 Implementations of this interface may leave with any of KErrNotSupported, KErrHttpEncodeDoWWWAuthenticate,
200 KErrHttpEncodeAuthorization, KErrHttpEncodeDoAge, KErrHttpEncodeDoVary, KErrHttpEncodeDoContentLanguage.
202 Specific header writer sub-classes must implement this method.
203 @param aHeader (in) A proxy for the header field to be encoded
205 //##ModelId=3C4C188601FA
206 virtual void EncodeHeaderL(RHeaderField& aHeader) = 0;
208 protected: // methods
213 IMPORT_C CHeaderWriter();
216 Second phase construction in which any necessary allocation is done
217 Implementations of this interface may leave with standard errors like KErrNoMemory.
219 //##ModelId=3C4C188601F9
220 IMPORT_C void ConstructL();
225 Intended Usage: Reserve a slot in the v-table to preserve future BC
227 //##ModelId=3C4C188601F1
228 inline virtual void Reserved1();
231 Intended Usage: Reserve a slot in the v-table to preserve future BC
233 //##ModelId=3C4C188601F0
234 inline virtual void Reserved2();
238 //##ModelId=3C4C188602FE
239 class CHeaderReader : public CBase
241 An abstract HTTP header decoder. CHeaderReader provides an interface used by its
242 owning codec to do conversion of header data from the raw representation used for
243 a particular protocol/transport to the generic internal header representation.
244 Specific sub-classes of CHeaderWriter are associated with specific protocol
253 Intended Usage: Destructor - cleans up and release resources to the system.
255 //##ModelId=3C4C1886031E
256 IMPORT_C virtual ~CHeaderReader();
259 Intended Usage: Decodes the supplied header field. This method does a conversion
260 of the field from the generic internal representation into raw form.
262 Specific header reader sub-classes must implement this method.
264 Implementations of this interface may leave with any of KErrHttpDecodeAccept, KErrHttpDecodeAcceptCharset,
265 KErrHttpDecodeAcceptLanguage, KErrHttpDecodeAcceptEncoding, KErrNotSupported.
267 @param aHeader (in) A proxy for the header field to be decoded
270 //##ModelId=3C4C1886031C
271 virtual void DecodeHeaderL(RHeaderField& aHeader) = 0;
273 protected: // methods
278 IMPORT_C CHeaderReader();
281 Second phase construction in which any necessary allocation is done
282 Implementations of this interface may leave with standard errors like KErrNoMemory.
284 //##ModelId=3C4C18860315
285 IMPORT_C void ConstructL();
290 Intended Usage: Reserve a slot in the v-table to preserve future BC
292 //##ModelId=3C4C18860314
293 inline virtual void Reserved1();
296 Intended Usage: Reserve a slot in the v-table to preserve future BC
298 //##ModelId=3C4C18860313
299 inline virtual void Reserved2();
303 inline void CHeaderCodec::Reserved1()
305 inline void CHeaderCodec::Reserved2()
307 inline void CHeaderWriter::Reserved1()
309 inline void CHeaderWriter::Reserved2()
311 inline void CHeaderReader::Reserved1()
313 inline void CHeaderReader::Reserved2()
316 #endif /* __CHEADERCODEC_H__ */