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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
19 @file CHTTPFormEncoder.h
20 @warning : This file contains Rose Model ID comments - please do not delete
23 #ifndef __CHTTPFORMENCODER__
24 #define __CHTTPFORMENCODER__
27 #include <http/mhttpdatasupplier.h>
29 //##ModelId=3C4C187902EB
30 class CHTTPFormEncoder : public CBase, public MHTTPDataSupplier
32 A data supplier class that is used to build up data that is to be encoded to application/x-www-form-urlencoded.
34 A client will create an instance of this class and add name/value pairs. They then use this as the data supplier for the
35 body of an http request that is a forms submission.
37 The name and value must both be supplied in the correct character encoding that you want to send to the server. This then
44 //##ModelId=3C4C18790347
45 IMPORT_C static CHTTPFormEncoder* NewL();
46 //##ModelId=3C4C18790346
47 IMPORT_C ~CHTTPFormEncoder();
49 // from MHTTPDataSupplier
50 //##ModelId=3C4C1879033D
51 virtual TBool GetNextDataPart(TPtrC8& aDataPart);
52 //##ModelId=3C4C1879033C
53 virtual void ReleaseData();
54 //##ModelId=3C4C1879033B
55 virtual TInt OverallDataSize();
57 //##ModelId=3C4C18790335
60 /** Adds a field to the data.
61 A field consists a name and value pair
62 @param aFieldName A name. This must not be empty
63 @param aFieldValue A value. This may be an empty descriptor
64 @leave KErrNoMemory There was not enough memory
65 @leave KErrArgument aFieldName was empty
66 @panic Will panic if called after the first data has been supplied or OverallDataSize has been called
68 //##ModelId=3C4C18790332
69 IMPORT_C void AddFieldL(const TDesC8& aFieldName, const TDesC8& aFieldValue);
73 //##ModelId=3C4C18790331
75 //##ModelId=3C4C1879032A
78 //##ModelId=3C4C18790328
79 TBool IsAlphaNumeric(TUint8 aChar);
80 //##ModelId=3C4C1879031F
81 void AppendSpecialChar(TUint8 aChar);
82 //##ModelId=3C4C1879031D
83 void AppendData(const TDesC8& aData);
86 enum THTTPFormEncoderState
88 EAllowAppendData, // when first constructed
90 ESupplyingData, // GetDataChunk has been called but ReleaseData has not
94 //##ModelId=3C4C18790315
95 THTTPFormEncoderState iState;
96 //##ModelId=3C4C1879030D
97 HBufC8* iData; // data is ALWAYS kept in the form-url-encoded format
100 #endif // __CHTTPFORMENCODER__