|
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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 |
|
17 |
|
18 /** |
|
19 @file RHTTPHeaders.h |
|
20 @warning : This file contains Rose Model ID comments - please do not delete |
|
21 */ |
|
22 |
|
23 #ifndef __RHTTPHEADERS_H__ |
|
24 #define __RHTTPHEADERS_H__ |
|
25 |
|
26 // System includes |
|
27 #include <http/thttphdrfielditer.h> |
|
28 #include <http/thttphdrval.h> |
|
29 |
|
30 |
|
31 //##ModelId=3C4C1880001A |
|
32 class RHTTPHeaders |
|
33 /** |
|
34 The collection of headers (or more correctly, header fields) |
|
35 associated with a message. Header (fields) can be created, read and |
|
36 modified. They may be composed of several parts (by repeated |
|
37 invocations of API methods, see below) and may be assigned one or |
|
38 more parameters. Individual field parts and parameters take |
|
39 values described using THTTPHdrVal. |
|
40 @publishedAll |
|
41 @released |
|
42 @see RHTTPMessage |
|
43 @see THTTPHdrVal |
|
44 */ |
|
45 { |
|
46 public: |
|
47 /** Default constructor |
|
48 */ |
|
49 //##ModelId=3C4C18800088 |
|
50 inline RHTTPHeaders(); |
|
51 |
|
52 /**Getter methods |
|
53 Methods for reading data. |
|
54 */ |
|
55 //@{ |
|
56 /** Obtain the number of parts in the named header field's value, |
|
57 Simple headers are created with a single part following one |
|
58 call to SetFieldL. Subsequent calls to SetFieldL create |
|
59 additional parts if the field exists already. |
|
60 @leave KErrNoMemory |
|
61 @param aFieldName The header name |
|
62 @return The number of parts, or zero if the field does not exist. */ |
|
63 //##ModelId=3C4C18800081 |
|
64 IMPORT_C TInt FieldPartsL(RStringF aFieldName) const; |
|
65 |
|
66 /** Obtain the named header field's value. The index |
|
67 of a part within the field must be specified. Parts are indexed |
|
68 from 0 and fields with only one part return the entire field for index 0 |
|
69 @param aFieldName The header name |
|
70 @param aPartIdx The index of the part |
|
71 @param aHeaderValue The header field value |
|
72 @return An error condition. Returns KErrNotFound if there is not a field with the |
|
73 specifed field name |
|
74 */ |
|
75 //##ModelId=3C4C18800079 |
|
76 IMPORT_C TInt GetField(RStringF aFieldName, |
|
77 TInt aPartIdx, THTTPHdrVal& aHeaderValue) const; |
|
78 |
|
79 /** Obtain an Raw representation of the named header |
|
80 field's value. Note that general client use of this method is |
|
81 strongly discouraged since it exposes the Raw representation of particular headers. |
|
82 However it may be needed for some cases where received headers could not be |
|
83 decoded by HTTP. It will normally be used internally when |
|
84 preparing header data to be transmitted with a request. |
|
85 Note that this API may not return the field values for all the headers. |
|
86 @param aFieldName The field name, e.g, 'Content-Type' |
|
87 @param aRawFieldData The field's data content, in an appropriate Raw form |
|
88 @return An error condition. Returns KErrNotFound if there is not a field with the |
|
89 specifed field name |
|
90 */ |
|
91 //##ModelId=3C4C18800076 |
|
92 IMPORT_C TInt GetRawField(RStringF aFieldName, |
|
93 TPtrC8& aRawFieldData) const; |
|
94 |
|
95 /** Obtain the value of a named parameter, associated with the |
|
96 named header field. An optional index to a part within the |
|
97 header field may be supplied, if not it is assumed that it is |
|
98 the first part. |
|
99 @param aFieldName The header name |
|
100 @param aParamName The parameter name |
|
101 @param aReturn The returned value. Note that this |
|
102 must be Copy()d by the caller, if it wants to keep the value. |
|
103 @param aPartIdx The optional index of the part |
|
104 @return An error condition. Returns KErrNotFound if there is not a field with the |
|
105 specifed field name */ |
|
106 //##ModelId=3C4C1880006C |
|
107 IMPORT_C TInt GetParam(RStringF aFieldName, |
|
108 RStringF aParamName, |
|
109 THTTPHdrVal& aReturn, |
|
110 TInt aPartIdx = 0) const; |
|
111 |
|
112 /** Access the fields within this header collection, via an |
|
113 iterator. Each application of the iterator returns the name |
|
114 of the next field type. This may then be accessed via |
|
115 RHTTPHeaders methods. |
|
116 @return The iterator. */ |
|
117 //##ModelId=3C4C1880006B |
|
118 IMPORT_C THTTPHdrFieldIter Fields() const; |
|
119 //@} |
|
120 |
|
121 /** Setter Methods |
|
122 Methods for writing data. |
|
123 */ |
|
124 //@{ |
|
125 /** Set a named field in the header. On the first instance that |
|
126 this API method is used for a given field name, the first will |
|
127 be created. On subsequent calls, the same field will be |
|
128 extended to have several parts, with a new part created to |
|
129 hold the supplied value. |
|
130 @param aFieldName The field name, e.g, 'Content-Type' |
|
131 @param aFieldValue The field value, e.g. 'text/html' */ |
|
132 //##ModelId=3C4C18800060 |
|
133 IMPORT_C void SetFieldL(RStringF aFieldName, THTTPHdrVal aFieldValue); |
|
134 |
|
135 /** Set a named field in the header, and associate with it the |
|
136 supplied parameter. If the field doesn't already exist it will |
|
137 be created along with a parameter; if it does exist, then a |
|
138 new part will be created along with the parameter. |
|
139 @param aFieldName The field name, e.g. 'Accept' |
|
140 @param aFieldValue The field value. e.g. 'text/plain' |
|
141 @param aParamName The parameter name, e.g. 'q' |
|
142 @param aParamValue The parameter value, e.g. '0.3' */ |
|
143 //##ModelId=3C4C18800063 |
|
144 IMPORT_C void SetFieldL(RStringF aFieldName, THTTPHdrVal aFieldValue, |
|
145 RStringF aParamName, THTTPHdrVal aParamValue); |
|
146 |
|
147 /** Set a parameter in an existing header. |
|
148 @param aFieldName The field name, e.g. 'Accept' |
|
149 @param aPartIdx The part of the header to add the parameter to |
|
150 @param aParamName The parameter name, e.g. 'q' |
|
151 @param aParamValue The parameter value, e.g. '0.3' |
|
152 @leave KErrNotFoud if the field, or the part within the field doesn't exist |
|
153 */ |
|
154 //##ModelId=3C4C18800058 |
|
155 IMPORT_C void SetParamL(RStringF aFieldName, RStringF aParamName, THTTPHdrVal aParamValue, TInt aPartIdx); |
|
156 |
|
157 /** Set a named field in the header to contain the supplied Raw header |
|
158 data. If the header already exists then a LF and the new data will be added to the existing data. This is used to |
|
159 indicate that there are multiple instances of this header |
|
160 |
|
161 |
|
162 Note that general client use of this method is strongly |
|
163 discouraged since it exposes the raw representation of particular headers. |
|
164 However it may be needed for some cases where headers to be transmitted have no encoding known |
|
165 to HTTP. It will normally be used internally when receiving data from a service provider. |
|
166 @param aFieldName The field name, e.g, 'Content-Type' |
|
167 @param aRawFieldData The field's data content, in a raw form |
|
168 @param aFieldSeparator The header field separator |
|
169 */ |
|
170 //##ModelId=3C4C1880004F |
|
171 IMPORT_C void SetRawFieldL(RStringF aFieldName, |
|
172 const TDesC8& aRawFieldData, |
|
173 const TDesC8& aFieldSeparator); |
|
174 |
|
175 /** Remove, entirely, the named header field from the header |
|
176 collection. All its parts and associated parameters (where |
|
177 they exist) are also removed. |
|
178 @param aFieldName The field name. |
|
179 @return KErrNone if the removal is successful; KErrNotFound if |
|
180 the field didn't exist within the headers. */ |
|
181 //##ModelId=3C4C1880004D |
|
182 IMPORT_C TInt RemoveField(RStringF aFieldName); |
|
183 |
|
184 /** Remove a single part of a header field. Just the part and any associated paramters are removed. If this |
|
185 results in no parts being present in the header then it will also be removed |
|
186 @param aFieldName The header name |
|
187 @param aIndex The particular part of the field to be removed |
|
188 @return KErrNone if the removal is sucessful; KErrNotFound if the header didn't exist. No exception is raised if |
|
189 the particular value is not found as part of that header */ |
|
190 //##ModelId=3C4C18800043 |
|
191 IMPORT_C TInt RemoveFieldPart(RStringF aFieldName, TInt aIndex); |
|
192 |
|
193 /** Remove all the fields of this header collection |
|
194 */ |
|
195 //##ModelId=3C4C18800042 |
|
196 IMPORT_C void RemoveAllFields(); |
|
197 |
|
198 //@} |
|
199 |
|
200 |
|
201 private: |
|
202 friend class CHeaders; |
|
203 //##ModelId=3C4C1880003A |
|
204 CHeaders* iImplementation; |
|
205 }; |
|
206 |
|
207 |
|
208 inline RHTTPHeaders::RHTTPHeaders() |
|
209 : iImplementation(NULL) |
|
210 { |
|
211 } |
|
212 |
|
213 |
|
214 #endif // __RHTTPHEADERS_H__ |