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