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