|         |      1 // Copyright (c) 2003-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 #ifndef __CHTTPRESPONSEPARSER_H__ | 
|         |     17 #define __CHTTPRESPONSEPARSER_H__ | 
|         |     18  | 
|         |     19 #include <e32base.h> | 
|         |     20 #include <http/framework/crxdata.h> | 
|         |     21 #include <http/framework/logging.h> | 
|         |     22  | 
|         |     23 #include "mhttpmessageparserobserver.h" | 
|         |     24 #include "rhttpmessageparser.h" | 
|         |     25 #include "mhttpresponse.h" | 
|         |     26 #include "timerlogger.h" | 
|         |     27  | 
|         |     28 class MHttpResponseObserver; | 
|         |     29  | 
|         |     30 class CHttpResponseParser : public CRxData, | 
|         |     31 							public MHttpResponse, | 
|         |     32 							public MHttpMessageParserObserver | 
|         |     33 	{ | 
|         |     34 public: | 
|         |     35  | 
|         |     36 	static CHttpResponseParser* NewL(CProtTransaction& aProtTrans, MRxDataObserver& aObserver, MHttpResponseObserver& aResponseObserver); | 
|         |     37 	virtual ~CHttpResponseParser(); | 
|         |     38  | 
|         |     39 	TInt CancelTransaction(TInt aError); | 
|         |     40 	void ConvertToNotifyOnDisconnectError ( TInt& aError ); | 
|         |     41  | 
|         |     42 public:	// methods from CRxData | 
|         |     43  | 
|         |     44 	virtual void ResetRxData(); | 
|         |     45 	 | 
|         |     46 private:	// methods from MHTTPDataSupplier via CRxData | 
|         |     47  | 
|         |     48 	virtual TBool GetNextDataPart(TPtrC8& aDataPart); | 
|         |     49 	virtual void ReleaseData(); | 
|         |     50 	virtual TInt OverallDataSize(); | 
|         |     51 	virtual TInt Reset(); | 
|         |     52 	 | 
|         |     53 private:	// methods from MHttpResponse | 
|         |     54  | 
|         |     55 	virtual void ResponseDataReceived(const TDesC8& aData); | 
|         |     56 	virtual void CancelResponse(); | 
|         |     57 	virtual void ConnectionError(TInt aError);	 | 
|         |     58 	virtual TBool ResponseCompleted (); | 
|         |     59  | 
|         |     60 	virtual TBool NeedCompletion ();	 | 
|         |     61 	virtual TBool CompleteResponse ( const TDesC8& aData ); | 
|         |     62 	virtual void FailTransactionL(); | 
|         |     63 	virtual void OnResponseReceiveTimeOut (); | 
|         |     64 	virtual TInt ReceiveTimeOutValue (); | 
|         |     65 	TBool ResponseInformational (); | 
|         |     66  | 
|         |     67 private:	// methods from MHttpMessageParserObserver | 
|         |     68  | 
|         |     69 	virtual void GetDataPacket(TPtrC8& aData); | 
|         |     70 	virtual void ReleaseDataPacket(); | 
|         |     71  | 
|         |     72 	virtual void StartLineL(const TDesC8& aStartLine); | 
|         |     73 	virtual void HeaderL(const TDesC8& aFieldName, TDesC8& aFieldValue); | 
|         |     74 	virtual TInt BodySizeL(); | 
|         |     75 	virtual void BodyChunkL(const TDesC8& aData); | 
|         |     76 	virtual void BodyCompleteL(); | 
|         |     77 	virtual void MessageCompleteL(const TPtrC8& aExcessData); | 
|         |     78  | 
|         |     79 	virtual TInt HandleParserError(TInt aError); | 
|         |     80  | 
|         |     81 	virtual void Reserved_MHttpMessageParserObserver(); | 
|         |     82  | 
|         |     83 private: | 
|         |     84  | 
|         |     85 	CHttpResponseParser(CProtTransaction& aProtTrans, MRxDataObserver& aObserver, MHttpResponseObserver& aResponseObserver); | 
|         |     86 	void ConstructL(); | 
|         |     87  | 
|         |     88 	void NotifyObserverError(TInt aError); | 
|         |     89  | 
|         |     90 	TBool CheckForNonPersistentConnection(); | 
|         |     91  | 
|         |     92 	inline TBool ConsumingResponse(); | 
|         |     93 	inline TBool BodyComplete(); | 
|         |     94 	inline TBool MessageComplete(); | 
|         |     95 	inline TBool GotTrailers(); | 
|         |     96 	inline TBool NotifyReleaseData(); | 
|         |     97     inline TBool BodyPresent(); | 
|         |     98      | 
|         |     99 private: | 
|         |    100  | 
|         |    101 	enum THttpResponseFlags | 
|         |    102 		{ | 
|         |    103 		EConsumingResponse		= 0x01, | 
|         |    104 		EBodyComplete			= 0x02, | 
|         |    105 		EMessageComplete		= 0x04, | 
|         |    106 		EGotTrailers			= 0x08, | 
|         |    107 	    ENotifyReleaseData		= 0x10, | 
|         |    108 		EBodyPresent			= 0x20 | 
|         |    109  | 
|         |    110 		}; | 
|         |    111  | 
|         |    112 private: | 
|         |    113 	TBool				iCancellingResponse;	 | 
|         |    114 	TInt				iOverallDataSize; | 
|         |    115 	TInt				iFlags; | 
|         |    116 	const TStringTable&    iStringTable; | 
|         |    117 	MHttpResponseObserver&	iResponseObserver; | 
|         |    118 	RHttpMessageParser		iMessageParser; | 
|         |    119 	TPtrC8				iRawData; | 
|         |    120 	 | 
|         |    121 	RArray<TPtrC8>		iBodyParts; | 
|         |    122  | 
|         |    123 	 | 
|         |    124 	__DECLARE_PERFORMANCE_LOG | 
|         |    125 public: | 
|         |    126  | 
|         |    127 	__FLOG_DECLARATION_MEMBER2 | 
|         |    128  | 
|         |    129 	}; | 
|         |    130  | 
|         |    131 inline TBool CHttpResponseParser::ConsumingResponse() | 
|         |    132 	{ | 
|         |    133 	return iFlags & EConsumingResponse; | 
|         |    134 	} | 
|         |    135  | 
|         |    136 inline TBool CHttpResponseParser::BodyComplete() | 
|         |    137 	{ | 
|         |    138 	return iFlags & EBodyComplete; | 
|         |    139 	} | 
|         |    140  | 
|         |    141 inline TBool CHttpResponseParser::MessageComplete() | 
|         |    142 	{ | 
|         |    143 	return iFlags & EMessageComplete; | 
|         |    144 	} | 
|         |    145  | 
|         |    146 inline TBool CHttpResponseParser::GotTrailers() | 
|         |    147 	{ | 
|         |    148 	return iFlags & EGotTrailers; | 
|         |    149 	} | 
|         |    150  | 
|         |    151 inline TBool CHttpResponseParser::NotifyReleaseData() | 
|         |    152 	{ | 
|         |    153 	return iFlags & ENotifyReleaseData; | 
|         |    154 	} | 
|         |    155 	 | 
|         |    156 	inline TBool CHttpResponseParser::BodyPresent() | 
|         |    157 	{ | 
|         |    158 	return iFlags & EBodyPresent; | 
|         |    159 	} | 
|         |    160  | 
|         |    161  | 
|         |    162 #endif	// __CHTTPRESPONSEPARSER_H__ |