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.
17 @file CHTTPFormEncoder.h
18 @warning : This file contains Rose Model ID comments - please do not delete
21 #ifndef __CHTTPFORMENCODER__
22 #define __CHTTPFORMENCODER__
25 #include <http/mhttpdatasupplier.h>
27 //##ModelId=3C4C187902EB
28 class CHTTPFormEncoder : public CBase, public MHTTPDataSupplier
30 A data supplier class that is used to build up data that is to be encoded to application/x-www-form-urlencoded.
32 A client will create an instance of this class and add name/value pairs. They then use this as the data supplier for the
33 body of an http request that is a forms submission.
35 The name and value must both be supplied in the correct character encoding that you want to send to the server. This then
42 //##ModelId=3C4C18790347
43 IMPORT_C static CHTTPFormEncoder* NewL();
44 //##ModelId=3C4C18790346
45 IMPORT_C ~CHTTPFormEncoder();
47 // from MHTTPDataSupplier
48 //##ModelId=3C4C1879033D
49 virtual TBool GetNextDataPart(TPtrC8& aDataPart);
50 //##ModelId=3C4C1879033C
51 virtual void ReleaseData();
52 //##ModelId=3C4C1879033B
53 virtual TInt OverallDataSize();
55 //##ModelId=3C4C18790335
58 /** Adds a field to the data.
59 A field consists a name and value pair
60 @param aFieldName A name. This must not be empty
61 @param aFieldValue A value. This may be an empty descriptor
62 @leave KErrNoMemory There was not enough memory
63 @leave KErrArgument aFieldName was empty
64 @panic Will panic if called after the first data has been supplied or OverallDataSize has been called
66 //##ModelId=3C4C18790332
67 IMPORT_C void AddFieldL(const TDesC8& aFieldName, const TDesC8& aFieldValue);
71 //##ModelId=3C4C18790331
73 //##ModelId=3C4C1879032A
76 //##ModelId=3C4C18790328
77 TBool IsAlphaNumeric(TUint8 aChar);
78 //##ModelId=3C4C1879031F
79 void AppendSpecialChar(TUint8 aChar);
80 //##ModelId=3C4C1879031D
81 void AppendData(const TDesC8& aData);
84 enum THTTPFormEncoderState
86 EAllowAppendData, // when first constructed
88 ESupplyingData, // GetDataChunk has been called but ReleaseData has not
92 //##ModelId=3C4C18790315
93 THTTPFormEncoderState iState;
94 //##ModelId=3C4C1879030D
95 HBufC8* iData; // data is ALWAYS kept in the form-url-encoded format
98 #endif // __CHTTPFORMENCODER__