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 __MHTTPDATASUPPLIER_H__
22 #define __MHTTPDATASUPPLIER_H__
28 //##ModelId=3C4C187903E5
29 class MHTTPDataSupplier
31 A data supplier - This class is used to deliver the response data
32 to the client, and is also used by the client to supply request
33 body data to HTTP in POST transactions. Data is supplied in a
34 number of parts. When a part is available it can be retreived
35 with GetNextDataPart. The returned descriptor will remain valid until
36 ReleaseData is called.
38 To use this class to supply POST data, you have a number of
39 options. If the post data needs to be URL Form encoded, you should
40 use CHTTPFormEncoder, which will do the encoding and interface to
41 the MHTTPDataSupplier for you. If you have all the data available,
42 return its length in OverallDataSize, and pass back all the data
43 from GetNextDataPart, returning ETrue to indicate that this is the
46 If you don't want to form all the data at once, but know how much
47 you'll eventualy have, return the total length from
48 OverallDataSize. When GetNextDataPart is first called, return the
49 first part. If GetNextDataPart is called again before ReleaseData,
50 you should still return the first part. Only when ReleaseData is
51 called should you move to the second part. If you don't know the
52 total size of the data, the procedure is the same but you should
53 return KErrNotFound from OverallDataSize.
55 When the next part is available, clients should call
56 RHTTPTransaction::NotifyNewRequestBodyPartL to inform HTTP that
57 the new data is available. They can do this from ReleaseData if
58 more data is instantly available, or in some applications they may
59 need to call it some time later when the next part has been
62 Filter writers should note that the MHTTPDataSupplier interface is
63 designed to be used by 1 client, as 1 component needs to know when
64 to call ReleaseData(). However, filters can be written to
65 transform the data in some way. For instance, a filter could be
66 written to automaticaly handle a particular content encoding. When
67 this filter first receives a GotResponseBodyData, it should take a
68 copy of the response's body and replace the body with a
69 MHTTPDataSupplier supplied by the filter. The filter should then
70 receive the data from HTTP via the saved data supplier and give it
71 to the client via its own data supplier.
77 /** Obtain a data part from the supplier. The data is guaranteed
78 to survive until a call is made to ReleaseData().
79 @param aDataPart - the data part
80 @return ETrue if this is the last part. EFalse otherwise */
81 //##ModelId=3C4C187A0026
82 virtual TBool GetNextDataPart(TPtrC8& aDataPart) = 0;
84 /** Release the current data part being held at the data
85 supplier. This call indicates to the supplier that the part
86 is no longer needed, and another one can be supplied, if
88 //##ModelId=3C4C187A0025
89 virtual void ReleaseData() = 0;
91 /** Obtain the overall size of the data being supplied, if known
92 to the supplier. Where a body of data is supplied in several
93 parts this size will be the sum of all the part sizes. If
94 the size is not known, KErrNotFound is returned; in this case
95 the client must use the return code of GetNextDataPart to find
96 out when the data is complete.
98 @return A size in bytes, or KErrNotFound if the size is not known. */
99 //##ModelId=3C4C187A001D
100 virtual TInt OverallDataSize() = 0;
102 /** Reset the data supplier. This indicates to the data supplier that it should
103 return to the first part of the data. This could be used in a situation where
104 the data consumer has encountered an error and needs the data to be supplied
105 afresh. Even if the last part has been supplied (i.e. GetNextDataPart has
106 returned ETrue), the data supplier should reset to the first part.
108 If the supplier cannot reset it should return an error code; otherwise it should
109 return KErrNone, where the reset will be assumed to have succeeded*/
110 //##ModelId=3C4C187A001C
111 virtual TInt Reset() = 0;
114 // Some reserved methods for future expansion (e.g. better support
116 //##ModelId=3C4C187A001B
117 inline virtual void MHDS_Reserved1();
118 //##ModelId=3C4C187A0012
119 inline virtual void MHDS_Reserved2();
120 //##ModelId=3C4C187A0011
121 inline virtual void MHDS_Reserved3();
124 inline void MHTTPDataSupplier::MHDS_Reserved1()
127 inline void MHTTPDataSupplier::MHDS_Reserved2()
130 inline void MHTTPDataSupplier::MHDS_Reserved3()
133 #endif // __MHTTPDATASUPPLIER_H__