|
1 // Copyright (c) 2008-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 __MHTTPMESSAGEPARSEROBSERVER_H__ |
|
17 #define __MHTTPMESSAGEPARSEROBSERVER_H__ |
|
18 |
|
19 #include <e32std.h> |
|
20 |
|
21 class MHttpMessageParserObserver |
|
22 /** |
|
23 The MHttpMessageParserObserver class is the observer API for the http message |
|
24 parser. It allows the parser to notify its observer when it has found http |
|
25 message components, e.g. the start-line. |
|
26 |
|
27 Also, the parser uses this API to obtain the data buffer containg http |
|
28 message info. The observer is responsible for ensuring that the supplied |
|
29 buffer remains valid until the parser notifies it that it has finished with |
|
30 the data. |
|
31 @see RHttpMessageParser |
|
32 */ |
|
33 { |
|
34 public: // enums |
|
35 |
|
36 enum TEntityBodyType |
|
37 /** |
|
38 The TEntityBodyType enumeration specifies the types of entity body. These |
|
39 are used when informing the parser of the entity body size. |
|
40 */ |
|
41 { |
|
42 /** The entity body is chunk-encoded. |
|
43 */ |
|
44 EChunked = -2, |
|
45 |
|
46 /** The size of the entity body is not known. |
|
47 */ |
|
48 EUnknown = -1, |
|
49 |
|
50 /** There is no entity body or the size is zero. |
|
51 */ |
|
52 ENoBody = 0 |
|
53 }; |
|
54 |
|
55 public: // methods |
|
56 |
|
57 /** |
|
58 Obtain current data packet. The parser requires the data packet with the |
|
59 current http message data. The observer must ensure that the buffer remains |
|
60 valid until the parser releases the data. |
|
61 @param aData An output argument set to the buffer containing the |
|
62 current http message data. |
|
63 */ |
|
64 virtual void GetDataPacket(TPtrC8& aData) =0; |
|
65 |
|
66 /** |
|
67 Current data is no longer needed. The parser has finished with the current |
|
68 data buffer. The observer may release that buffer. |
|
69 */ |
|
70 virtual void ReleaseDataPacket() =0; |
|
71 |
|
72 /** |
|
73 The message start-line. The parser has found the message start-line. The |
|
74 observer is responsible for parsing it further as a request or status line. |
|
75 The parser ensures that the buffer containing the start-line remains valid |
|
76 for the duration of the call. |
|
77 */ |
|
78 virtual void StartLineL(const TDesC8& aStartLine) =0; |
|
79 |
|
80 /** |
|
81 A header has been found. The parser has found a header field. Any header |
|
82 values that were folded onto multiple lines have been merged into a single |
|
83 line - any LWS between header values has been replaced by a SP or HT. Any |
|
84 leading or trailing has been removed. Although, multiple SPs or HTs between |
|
85 tokens in the field value have not been reduced to a single SP. The parser |
|
86 ensures that the buffers containing the field name and value remain valid |
|
87 for the duration of the call. The observer is also notified of trailer |
|
88 header fields using this API. |
|
89 @param aFieldName The header field name. |
|
90 @param aFieldValue The header field value. |
|
91 */ |
|
92 virtual void HeaderL(const TDesC8& aFieldName, TDesC8& aFieldValue) =0; |
|
93 |
|
94 /** |
|
95 Request the size of the entity body. The parser has found the empty line that |
|
96 indicates the end of the header fields. The observer must indicate to the |
|
97 parser the size of entity body. The are four cases - |
|
98 |
|
99 1) EChunked - the entity is chunk-encoded. |
|
100 2) EUnknown - the enity body length is unknown. |
|
101 3) ENoBody - there is no entity body or the entity body length is zero. |
|
102 |
|
103 The fourth case is a positive value (greater than zero) that indicates the |
|
104 expected number of bytes in the entity body. |
|
105 @return An integer value greater than zero indicating the number bytes in |
|
106 the entity body. A value of EChunked indicates a chunked-body, |
|
107 EUnknown an unknown size and ENoBody indicates that there is no |
|
108 entity body. |
|
109 */ |
|
110 virtual TInt BodySizeL() =0; |
|
111 |
|
112 /** |
|
113 Entity body data. The parser has parsed entity body data. If the entity body |
|
114 was chunk-encoded the parser has removed the encoding. The supplied buffer |
|
115 contains just the body data and no encoding info. The parser does not do any |
|
116 copying of entity body data. Therefore the supplied buffer remains valid |
|
117 until the observer releases it. The observer should not release the data |
|
118 until the parser has notified it that it has finished with the current data |
|
119 packet. |
|
120 @param aData The buffer containing the entity body data. |
|
121 */ |
|
122 virtual void BodyChunkL(const TDesC8& aData) =0; |
|
123 |
|
124 /** |
|
125 The entity body has been parsed. The parser has parsed all of the entity |
|
126 body data. |
|
127 */ |
|
128 virtual void BodyCompleteL() =0; |
|
129 |
|
130 /** |
|
131 The message is complete. The parser has parsed the entire message. Any data |
|
132 in the current buffer that is part of the parsed message is supplied in the |
|
133 buffer argument. This data could be the start of the next message in the |
|
134 case where pipelining of requests has occurred. |
|
135 */ |
|
136 virtual void MessageCompleteL(const TPtrC8& aExcessData) =0; |
|
137 |
|
138 /** |
|
139 Error notifier. The parser has experienced an error. It has reset itself and |
|
140 is no longer able to continue parsing the current message. |
|
141 @param aError The error code. |
|
142 */ |
|
143 virtual TInt HandleParserError(TInt aError) =0; |
|
144 |
|
145 private: // methods |
|
146 |
|
147 /** |
|
148 Reserved function. |
|
149 */ |
|
150 // virtual void Reserved_MHttpMessageParserObserver() =0; |
|
151 |
|
152 }; |
|
153 |
|
154 #endif // __MHTTPMESSAGEPARSEROBSERVER_H__ |