epoc32/include/mw/http/mhttpdatasupplier.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 epoc32/include/http/mhttpdatasupplier.h@2fe1408b6811
child 4 837f303aceeb
permissions -rw-r--r--
Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
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 MHTTPDataSupplier.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	__MHTTPDATASUPPLIER_H__
williamr@2
    24
#define	__MHTTPDATASUPPLIER_H__
williamr@2
    25
williamr@2
    26
// System includes
williamr@2
    27
#include <e32base.h>
williamr@2
    28
williamr@2
    29
williamr@2
    30
//##ModelId=3C4C187903E5
williamr@2
    31
class MHTTPDataSupplier
williamr@2
    32
/** 
williamr@2
    33
A data supplier - This class is used to deliver the response data
williamr@2
    34
to the client, and is also used by the client to supply request
williamr@2
    35
body data to HTTP in POST transactions. Data is supplied in a
williamr@2
    36
number of parts. When a part is available it can be retreived
williamr@2
    37
with GetNextDataPart. The returned descriptor will remain valid until
williamr@2
    38
ReleaseData is called. 
williamr@2
    39
williamr@2
    40
To use this class to supply POST data, you have a number of
williamr@2
    41
options. If the post data needs to be URL Form encoded, you should
williamr@2
    42
use CHTTPFormEncoder, which will do the encoding and interface to
williamr@2
    43
the MHTTPDataSupplier for you. If you have all the data available,
williamr@2
    44
return its length in OverallDataSize, and pass back all the data
williamr@2
    45
from GetNextDataPart, returning ETrue to indicate that this is the
williamr@2
    46
last part. 
williamr@2
    47
williamr@2
    48
If you don't want to form all the data at once, but know how much
williamr@2
    49
you'll eventualy have, return the total length from
williamr@2
    50
OverallDataSize. When GetNextDataPart is first called, return the
williamr@2
    51
first part. If GetNextDataPart is called again before ReleaseData,
williamr@2
    52
you should still return the first part. Only when ReleaseData is
williamr@2
    53
called should you move to the second part. If you don't know the
williamr@2
    54
total size of the data, the procedure is the same but you should
williamr@2
    55
return KErrNotFound from OverallDataSize.
williamr@2
    56
williamr@2
    57
When the next part is available, clients should call
williamr@2
    58
RHTTPTransaction::NotifyNewRequestBodyPartL to inform HTTP that
williamr@2
    59
the new data is available. They can do this from ReleaseData if
williamr@2
    60
more data is instantly available, or in some applications they may
williamr@2
    61
need to call it some time later when the next part has been
williamr@2
    62
assembled.
williamr@2
    63
williamr@2
    64
Filter writers should note that the MHTTPDataSupplier interface is
williamr@2
    65
designed to be used by 1 client, as 1 component needs to know when
williamr@2
    66
to call ReleaseData(). However, filters can be written to
williamr@2
    67
transform the data in some way. For instance, a filter could be
williamr@2
    68
written to automaticaly handle a particular content encoding. When
williamr@2
    69
this filter first receives a GotResponseBodyData, it should take a
williamr@2
    70
copy of the response's body and replace the body with a
williamr@2
    71
MHTTPDataSupplier supplied by the filter. The filter should then
williamr@2
    72
receive the data from HTTP via the saved data supplier and give it
williamr@2
    73
to the client via its own data supplier.
williamr@2
    74
@publishedAll
williamr@2
    75
@released
williamr@2
    76
*/
williamr@2
    77
	{
williamr@2
    78
 public:
williamr@2
    79
	/** Obtain a data part from the supplier.  The data is guaranteed
williamr@2
    80
		to survive until a call is made to ReleaseData().
williamr@2
    81
		@param aDataPart - the data part
williamr@2
    82
		@return ETrue if this is the last part. EFalse otherwise */
williamr@2
    83
	//##ModelId=3C4C187A0026
williamr@2
    84
	 virtual TBool GetNextDataPart(TPtrC8& aDataPart) = 0;
williamr@2
    85
williamr@2
    86
	/** Release the current data part being held at the data
williamr@2
    87
		supplier.  This call indicates to the supplier that the part
williamr@2
    88
		is no longer needed, and another one can be supplied, if
williamr@2
    89
		appropriate.  */
williamr@2
    90
	//##ModelId=3C4C187A0025
williamr@2
    91
	virtual void ReleaseData() = 0;
williamr@2
    92
williamr@2
    93
	/** Obtain the overall size of the data being supplied, if known
williamr@2
    94
		to the supplier.  Where a body of data is supplied in several
williamr@2
    95
		parts this size will be the sum of all the part sizes. If
williamr@2
    96
		the size is not known, KErrNotFound is returned; in this case
williamr@2
    97
		the client must use the return code of GetNextDataPart to find
williamr@2
    98
		out when the data is complete.
williamr@2
    99
williamr@2
   100
		@return A size in bytes, or KErrNotFound if the size is not known.  */
williamr@2
   101
	//##ModelId=3C4C187A001D
williamr@2
   102
	virtual TInt OverallDataSize() = 0;
williamr@2
   103
williamr@2
   104
	/** Reset the data supplier.  This indicates to the data supplier that it should
williamr@2
   105
		return to the first part of the data.  This could be used in a situation where
williamr@2
   106
		the data consumer has encountered an error and needs the data to be supplied
williamr@2
   107
		afresh.  Even if the last part has been supplied (i.e. GetNextDataPart has
williamr@2
   108
		returned ETrue), the data supplier should reset to the first part.
williamr@2
   109
	
williamr@2
   110
		If the supplier cannot reset it should return an error code; otherwise it should
williamr@2
   111
		return KErrNone, where the reset will be assumed to have succeeded*/
williamr@2
   112
	//##ModelId=3C4C187A001C
williamr@2
   113
	virtual TInt Reset() = 0;
williamr@2
   114
williamr@2
   115
private:
williamr@2
   116
	// Some reserved methods for future expansion (e.g. better support
williamr@2
   117
	// for ZCD)
williamr@2
   118
	//##ModelId=3C4C187A001B
williamr@2
   119
	inline virtual void MHDS_Reserved1();
williamr@2
   120
	//##ModelId=3C4C187A0012
williamr@2
   121
	inline virtual void MHDS_Reserved2();
williamr@2
   122
	//##ModelId=3C4C187A0011
williamr@2
   123
	inline virtual void MHDS_Reserved3();
williamr@2
   124
	};
williamr@2
   125
williamr@2
   126
inline void MHTTPDataSupplier::MHDS_Reserved1()
williamr@2
   127
	{}
williamr@2
   128
williamr@2
   129
inline void MHTTPDataSupplier::MHDS_Reserved2()
williamr@2
   130
	{}
williamr@2
   131
williamr@2
   132
inline void MHTTPDataSupplier::MHDS_Reserved3()
williamr@2
   133
	{}
williamr@2
   134
williamr@2
   135
#endif // __MHTTPDATASUPPLIER_H__