📄 httpclientengine.h
字号:
/*
* ==============================================================================
* Name : CHttpClientEngine.h
* Part of : MOPlay V1 S60
* Description : Defines the CHttpClientEngine interface.
* Version : 1
* Author : Johnson
* Create date : 2007-4-11
* Last Update : Johnson
* Update date : 2007-5-29
* ==============================================================================
*/
#ifndef WEBCLIENTENGINE_H
#define WEBCLIENTENGINE_H
// INCLUDES
#include <coecntrl.h>
#include <http.h>
#include <http\mhttpauthenticationcallback.h>
// CONSTANTS
const TInt KMaxHeaderNameLength = 32;
const TInt KMaxHeaderValueLength = 128;
const TInt KMaxAuthTypeLength = 128;
const TInt KMaxDateTimeStringLength = 40;
const TInt KMaxStatusTextLength = 32;
// Used user agent for requests
_LIT8( KUserAgent, "WebClient 1.0" );
// This client accepts all content types.
// (change to e.g. "text/plain" for plain text only)
_LIT8( KAccept, "*/*" );
// Format for output of data/time values
_LIT( KDateFormat,"%D%M%Y%/0%1%/1%2%/2%3%/3 %:0%H%:1%T%:2%S.%C%:3" );
// Some texts for header output
_LIT( KColon, ": " );
_LIT( Krealm, "Realm: " );
// FORWARD DECLARATIONS
class CPluginAdapter;
#ifndef WEBCLIENTOBSERVER_H
#define WEBCLIENTOBSERVER_H
// CLASS DECLARATION
class MWebClientObserver
{
public:
virtual void ClientEvent( const TDesC& aEventDescription ) = 0;
public:
virtual void ClientHeaderReceived( const TDesC& aHeaderData ) = 0;
virtual void ClientBodyReceived( const TDesC8& aBodyData ) = 0;
virtual void ClientSuccess() = 0;
virtual void ClientFailed() = 0;
};
#endif
class CHttpClientEngine : public CBase,
public MHTTPTransactionCallback,
public MHTTPAuthenticationCallback
{
public:
static CHttpClientEngine* NewL( MWebClientObserver& aObserver );
static CHttpClientEngine* NewLC( MWebClientObserver& aObserver );
~CHttpClientEngine();
void IssueHTTPGetL( const TDesC8& aUri );
void CancelTransactionL();
inline TBool IsRunning() { return iRunning; };
private:
void ConstructL();
CHttpClientEngine( MWebClientObserver& iObserver );
void SetHeaderL( RHTTPHeaders aHeaders, TInt aHdrField,
const TDesC8& aHdrValue );
void DumpRespHeadersL( RHTTPTransaction& aTransantion );
void HandleRunErrorL( TInt aError );
private:
void MHFRunL( RHTTPTransaction aTransaction, const THTTPEvent& aEvent );
TInt MHFRunError( TInt aError,
RHTTPTransaction aTransaction,
const THTTPEvent& aEvent );
private:
TBool GetCredentialsL( const TUriC8& aUri,
RString aRealm,
RStringF aAuthenticationType,
RString& aUsername,
RString& aPassword );
private: // Data
RHTTPSession iSession;
RHTTPTransaction iTransaction;
MWebClientObserver& iObserver; // Used for passing body data and
// events to UI.
TBool iRunning; // ETrue, if transaction running
};
#endif // WEBCLIENTENGINE_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -