epoc32/include/mw/http/mhttpdatasupplier.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 3 e1b950c65cb4
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 /**
    17  @file
    18  @warning : This file contains Rose Model ID comments - please do not delete
    19 */
    20 
    21 #ifndef	__MHTTPDATASUPPLIER_H__
    22 #define	__MHTTPDATASUPPLIER_H__
    23 
    24 // System includes
    25 #include <e32base.h>
    26 
    27 
    28 //##ModelId=3C4C187903E5
    29 class MHTTPDataSupplier
    30 /** 
    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. 
    37 
    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
    44 last part. 
    45 
    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.
    54 
    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
    60 assembled.
    61 
    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.
    72 @publishedAll
    73 @released
    74 */
    75 	{
    76  public:
    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;
    83 
    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
    87 		appropriate.  */
    88 	//##ModelId=3C4C187A0025
    89 	virtual void ReleaseData() = 0;
    90 
    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.
    97 
    98 		@return A size in bytes, or KErrNotFound if the size is not known.  */
    99 	//##ModelId=3C4C187A001D
   100 	virtual TInt OverallDataSize() = 0;
   101 
   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.
   107 	
   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;
   112 
   113 private:
   114 	// Some reserved methods for future expansion (e.g. better support
   115 	// for ZCD)
   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();
   122 	};
   123 
   124 inline void MHTTPDataSupplier::MHDS_Reserved1()
   125 	{}
   126 
   127 inline void MHTTPDataSupplier::MHDS_Reserved2()
   128 	{}
   129 
   130 inline void MHTTPDataSupplier::MHDS_Reserved3()
   131 	{}
   132 
   133 #endif // __MHTTPDATASUPPLIER_H__