# HG changeset patch # User Dremov Kirill (Nokia-D-MSW/Tampere) # Date 1274955713 -10800 # Node ID 2f328ce1b2631c2836ec39ccfbbb3d86cf6fc22c # Parent cb0c8a2aff2d0e3f3a4abfe4ccc2d783b128e890 Revision: 201019 Kit: 2010121 diff -r cb0c8a2aff2d -r 2f328ce1b263 applayerprotocols/httpservice/EABI/httpserviceu.def --- a/applayerprotocols/httpservice/EABI/httpserviceu.def Fri May 14 16:23:37 2010 +0300 +++ b/applayerprotocols/httpservice/EABI/httpserviceu.def Thu May 27 13:21:53 2010 +0300 @@ -90,5 +90,11 @@ _ZTV17CHttpDataReceiver @ 89 NONAME _ZTV22CHttpClientTransaction @ 90 NONAME _ZTV26CHttpClientTransactionImpl @ 91 NONAME - + _ZN12CHttpService17SetAuthenticationEP26MHTTPServiceAuthentication @ 92 NONAME + _ZN12CHttpService21HttpNetworkConnectionEv @ 93 NONAME + _ZN22CHttpNetworkConnection4StopEv @ 94 NONAME + _ZN22CHttpNetworkConnection5StartE15TCommDbConnPrefi @ 95 NONAME + _ZN22CHttpNetworkConnection5StartEv @ 96 NONAME + _ZTI22CHttpNetworkConnection @ 97 NONAME + _ZTV22CHttpNetworkConnection @ 98 NONAME diff -r cb0c8a2aff2d -r 2f328ce1b263 applayerprotocols/httpservice/bwins/httpserviceU.def --- a/applayerprotocols/httpservice/bwins/httpserviceU.def Fri May 14 16:23:37 2010 +0300 +++ b/applayerprotocols/httpservice/bwins/httpserviceU.def Thu May 27 13:21:53 2010 +0300 @@ -64,4 +64,9 @@ ??0THttpHeaderElementIterator@@QAE@XZ @ 63 NONAME ; THttpHeaderElementIterator::THttpHeaderElementIterator(void) ?Parameter@THttpHeaderElementIterator@@QBE?AVTHttpHeaderParamIterator@@XZ @ 64 NONAME ; class THttpHeaderParamIterator THttpHeaderElementIterator::Parameter(void) const ?Notify@THttpContentSourceOp@@QAEXABVTDesC8@@H@Z @ 65 NONAME ; void THttpContentSourceOp::Notify(class TDesC8 const &, int) - + ?SetAuthentication@CHttpService@@QAEHPAVMHTTPServiceAuthentication@@@Z @ 66 NONAME ; int CHttpService::SetAuthentication(class MHTTPServiceAuthentication *) + ?Start@CHttpNetworkConnection@@QAEHVTCommDbConnPref@@H@Z @ 67 NONAME ; int CHttpNetworkConnection::Start(class TCommDbConnPref, int) + ?HttpNetworkConnection@CHttpService@@QAEPAVCHttpNetworkConnection@@XZ @ 68 NONAME ; class CHttpNetworkConnection * CHttpService::HttpNetworkConnection(void) + ?Stop@CHttpNetworkConnection@@QAEXXZ @ 69 NONAME ; void CHttpNetworkConnection::Stop(void) + ?Start@CHttpNetworkConnection@@QAEHXZ @ 70 NONAME ; int CHttpNetworkConnection::Start(void) + diff -r cb0c8a2aff2d -r 2f328ce1b263 applayerprotocols/httpservice/group/bld.inf --- a/applayerprotocols/httpservice/group/bld.inf Fri May 14 16:23:37 2010 +0300 +++ b/applayerprotocols/httpservice/group/bld.inf Thu May 27 13:21:53 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -29,6 +29,8 @@ // top-level includes ../inc/mhttpcontentsource.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(mhttpcontentsource.h) +../inc/mhttpserviceauthentication.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(mhttpserviceauthentication.h) +../inc/chttpnetworkconnectioninfo.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(chttpnetworkconnectioninfo.h) ../inc/mhttpcontentsink.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(mhttpcontentsink.h) ../inc/httpheaderiter.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(httpheaderiter.h) ../inc/chttpservice.h SYMBIAN_MW_LAYER_PUBLIC_EXPORT_PATH(chttpservice.h) @@ -39,20 +41,20 @@ // rom definition file httpservice.iby /epoc32/rom/include/httpservice.iby -../Test/Group/httpservicetest.iby /epoc32/rom/include/httpservicetest.iby +../test/group/httpservicetest.iby /epoc32/rom/include/httpservicetest.iby PRJ_TESTEXPORTS -../Test/testdata/scripts/HTTPServiceAPITest.script c:/testdata/scripts/httpserviceapitest.script -../Test/testdata/ini/httpclient.ini c:/httptest/httpservicetest/httpclient.ini -../Test/testdata/configs/ethernetced_httpserviceapi.xml c:/testdata/configs/ethernetced_httpserviceapi.xml -../Test/testdata/scripts/HTTPServiceAPITest.script z:/testdata/scripts/httpserviceapitest.script -../Test/testdata/ini/httpclient.ini z:/httptest/httpservicetest/httpclient.ini -../Test/testdata/configs/ethernetced_httpserviceapi.xml z:/testdata/configs/ethernetced_httpserviceapi.xml +../test/testdata/scripts/httpserviceapitest.script c:/testdata/scripts/httpserviceapitest.script +../test/testdata/ini/httpclient.ini c:/httptest/httpservicetest/httpclient.ini +../test/testdata/configs/ethernetced_httpserviceapi.xml c:/testdata/configs/ethernetced_httpserviceapi.xml +../test/testdata/scripts/httpserviceapitest.script z:/testdata/scripts/httpserviceapitest.script +../test/testdata/ini/httpclient.ini z:/httptest/httpservicetest/httpclient.ini +../test/testdata/configs/ethernetced_httpserviceapi.xml z:/testdata/configs/ethernetced_httpserviceapi.xml -../Test/testdata/httpservicetest/testdl.txt c:/httptest/httpservicetest/testdl.txt -../Test/testdata/httpservicetest/testdl2.txt c:/httptest/httpservicetest/testdl2.txt -../Test/testdata/httpservicetest/testdl.txt z:/httptest/httpservicetest/testdl.txt -../Test/testdata/httpservicetest/testdl2.txt z:/httptest/httpservicetest/testdl2.txt +../test/testdata/httpservicetest/testdl.txt c:/httptest/httpservicetest/testdl.txt +../test/testdata/httpservicetest/testdl2.txt c:/httptest/httpservicetest/testdl2.txt +../test/testdata/httpservicetest/testdl.txt z:/httptest/httpservicetest/testdl.txt +../test/testdata/httpservicetest/testdl2.txt z:/httptest/httpservicetest/testdl2.txt PRJ_TESTMMPFILES diff -r cb0c8a2aff2d -r 2f328ce1b263 applayerprotocols/httpservice/group/httpservice.mmp --- a/applayerprotocols/httpservice/group/httpservice.mmp Fri May 14 16:23:37 2010 +0300 +++ b/applayerprotocols/httpservice/group/httpservice.mmp Thu May 27 13:21:53 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -44,7 +44,7 @@ SOURCE chttpclienttransaction.cpp SOURCE httpheaderiter.cpp SOURCE httpclientutils.cpp chttpclienttransactionimpl.cpp -SOURCE chttpdatasender.cpp chttpdatareceiver.cpp chttpcontentreader.cpp chttpcontentwriter.cpp +SOURCE chttpdatasender.cpp chttpdatareceiver.cpp chttpcontentreader.cpp chttpcontentwriter.cpp chttpclientauthentication.cpp chttpnetworkconnectioninfo.cpp CConnectionMonitor.cpp LIBRARY euser.lib LIBRARY http.lib @@ -53,6 +53,7 @@ LIBRARY inetprotutil.lib LIBRARY bafl.lib LIBRARY efsrv.lib +LIBRARY ecom.lib DEFFILE httpservice.def diff -r cb0c8a2aff2d -r 2f328ce1b263 applayerprotocols/httpservice/inc/CConnectionMonitor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/applayerprotocols/httpservice/inc/CConnectionMonitor.h Thu May 27 13:21:53 2010 +0300 @@ -0,0 +1,45 @@ +// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// +#ifndef CCONNECTIONMONITOR_H_ +#define CCONNECTIONMONITOR_H_ +class CHttpNetworkConnection; + +NONSHARABLE_CLASS ( CConnectionMonitor ): public CActive + { + friend class CHttpNetworkConnection; + public: + static CConnectionMonitor* NewL( CHttpNetworkConnection* aNetworkConn ); + static CConnectionMonitor* NewLC(CHttpNetworkConnection* aNetworkConn ); + ~CConnectionMonitor(); + void HandleConnectionEvent(TInt aEvent); + + + protected: // from CActive + void DoCancel(); + void RunL(); + + private: + CConnectionMonitor( CHttpNetworkConnection* aNetworkConn ); + void ConstructL(); + RConnection Connection() ; + + private: + TNifProgressBuf iProgress; + CHttpNetworkConnection* iNetworkConnInfo; + + + }; + +#endif /* CCONNECTIONMONITOR_H_ */ diff -r cb0c8a2aff2d -r 2f328ce1b263 applayerprotocols/httpservice/inc/chttpclientauthentication.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/applayerprotocols/httpservice/inc/chttpclientauthentication.h Thu May 27 13:21:53 2010 +0300 @@ -0,0 +1,42 @@ +// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + + +#ifndef __CHTTPCLIENTAUTHENTICATION_H__ +#define __CHTTPCLIENTAUTHENTICATION_H__ + +#include +#include +class MHTTPServiceAuthentication; + +NONSHARABLE_CLASS(CHttpClientAuthentication) : public CBase, public MHTTPAuthenticationCallback + { +public: + static CHttpClientAuthentication* New(RHTTPSession aSesion, MHTTPServiceAuthentication* aCallback); + +// methods inherited from MHTTPAuthenticationCallback + virtual TBool GetCredentialsL(const TUriC8& aURI, RString aRealm, + RStringF aAuthenticationType, + RString& aUsername, + RString& aPassword); + +protected: + TInt Construct(RHTTPSession aSesion, MHTTPServiceAuthentication* aCallback); + void FillCredentialsL(RString& aRealm, RString& aUsername, RString& aPassword, RBuf8& aClientUsername, RBuf8& aClientPassword); +private: + MHTTPServiceAuthentication* iHTTPServiceAuthentication; + }; + +#endif __CHTTPCLIENTAUTHENTICATION_H__ diff -r cb0c8a2aff2d -r 2f328ce1b263 applayerprotocols/httpservice/inc/chttpclienttransaction.h --- a/applayerprotocols/httpservice/inc/chttpclienttransaction.h Fri May 14 16:23:37 2010 +0300 +++ b/applayerprotocols/httpservice/inc/chttpclienttransaction.h Thu May 27 13:21:53 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -90,7 +90,7 @@ private: // Reserved for future use. - inline virtual void Reserved(); + inline virtual void Reserved1(); inline virtual void Reserved2(); protected: @@ -101,11 +101,10 @@ CHttpClientTransactionImpl* iHttpClientTrans; }; -// Reserved for future use. -inline void CHttpClientTransaction::Reserved() - { - } - +inline void CHttpClientTransaction::Reserved1() + { + } + inline void CHttpClientTransaction::Reserved2() { } diff -r cb0c8a2aff2d -r 2f328ce1b263 applayerprotocols/httpservice/inc/chttpnetworkconnectioninfo.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/applayerprotocols/httpservice/inc/chttpnetworkconnectioninfo.h Thu May 27 13:21:53 2010 +0300 @@ -0,0 +1,71 @@ +// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#ifndef CHTTPNETWORKCONNECTIONINFO_H_ +#define CHTTPNETWORKCONNECTIONINFO_H_ + +#include +#include +#include "chttpservice.h" + + +class CConnectionMonitor; + +class CHttpNetworkConnection: public CBase + { + friend class CHttpClientTransactionImpl; + friend class CConnectionMonitor; + friend class CHttpService; + + public: + static CHttpNetworkConnection* New(); + IMPORT_C TInt Start();//start on default connection + IMPORT_C TInt Start(TCommDbConnPref aConnPref, TBool aAttachType=EFalse); + + IMPORT_C void Stop(); + + + + private: + TInt SetupConnection(); + void AssociateConnectionWithHttpSession(); + void HandleConnectionEvent(TInt aEvent); //Called whenever there is a connection event + void SetHttpService(CHttpService* aService); + RConnection Connection() + { + return iConnInfo->iConnection; + } + CHttpNetworkConnection(); + void ConstructL(); + + ~CHttpNetworkConnection(); + + + private: + class CConnectionInfo: public CBase + { + public: + TBool iConnectionStatus; + TBool iAttach; + TCommDbConnPref iConnPref; + RConnection iConnection; + RSocketServ iSocketServ; + }; + CConnectionMonitor* iConnectionMonitor; + CConnectionInfo* iConnInfo; + CHttpService* iHttpService; + }; + +#endif /* CHTTPNETWORKCONNECTIONINFO_H_ */ diff -r cb0c8a2aff2d -r 2f328ce1b263 applayerprotocols/httpservice/inc/chttpservice.h --- a/applayerprotocols/httpservice/inc/chttpservice.h Fri May 14 16:23:37 2010 +0300 +++ b/applayerprotocols/httpservice/inc/chttpservice.h Thu May 27 13:21:53 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -20,7 +20,7 @@ #include #include #include "httpheaderiter.h" - +class CHttpNetworkConnection; /** * CHttpService represent a handle to the HTTP service instance for a set of client * HTTP transactions[a request and its equivalent response]. The application can @@ -31,10 +31,12 @@ * @publishedAll * @prototype */ - +class CHttpClientAuthentication; +class MHTTPServiceAuthentication; class CHttpService : public CBase { friend class CHttpClientTransactionImpl; + friend class CHttpNetworkConnection; public: IMPORT_C static CHttpService* NewL(); @@ -54,16 +56,21 @@ IMPORT_C TInt AddRequestHeader(TInt aHeaderId, const THttpHeaderValueVariant& aHeaderValue); IMPORT_C TInt AddCustomRequestHeader(const TDesC8& aHeaderName, const TDesC8& aHeaderValue); + IMPORT_C TInt SetAuthentication(MHTTPServiceAuthentication* aCallback); + + IMPORT_C CHttpNetworkConnection* HttpNetworkConnection(); private: CHttpService(); void ConstructL(); - class CHttpServiceStruct : public CBase + NONSHARABLE_CLASS(CHttpServiceStruct) : public CBase { public: - RHTTPSession iHttpSession; - RHTTPHeaders iSessionHeaders; + ~CHttpServiceStruct(); + RHTTPSession iHttpSession; + RHTTPHeaders iSessionHeaders; + CHttpClientAuthentication* iHttpClientAuthentication; }; private: RHTTPSession Session() @@ -73,7 +80,7 @@ private: - CHttpServiceStruct* iHttpServiceStruct; // Implementation struct + CHttpServiceStruct* iHttpServiceStruct; // Implementation struct }; #endif // __CHTTPSERVICE_H__ diff -r cb0c8a2aff2d -r 2f328ce1b263 applayerprotocols/httpservice/inc/httpservice.h --- a/applayerprotocols/httpservice/inc/httpservice.h Fri May 14 16:23:37 2010 +0300 +++ b/applayerprotocols/httpservice/inc/httpservice.h Thu May 27 13:21:53 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -23,5 +23,7 @@ #include #include #include +#include +#include #endif // __MHTTPDATARECIVER_H__ diff -r cb0c8a2aff2d -r 2f328ce1b263 applayerprotocols/httpservice/inc/mhttpserviceauthentication.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/applayerprotocols/httpservice/inc/mhttpserviceauthentication.h Thu May 27 13:21:53 2010 +0300 @@ -0,0 +1,40 @@ +// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file MHTTPServiceAuthentication.h + */ + +#ifndef __MHTTPSERVICEAUTHENTICATION_H__ +#define __MHTTPSERVICEAUTHENTICATION_H__ + +// System includes +#include + +class MHTTPServiceAuthentication +/** +The mixin that needs to be implemented if authentication is to be +supported. This supplies the username and password when they are +needed for authentication. + +@publishedAll +@released +*/ + { + public: + virtual TInt OnAuthentication(const TDesC8& aUri, const TDesC8& aRealm, const TDesC8& aType, RBuf8& aUsername, RBuf8& aPassword) = 0; + }; + +#endif // __MHTTPSERVICEAUTHENTICATION_H__ diff -r cb0c8a2aff2d -r 2f328ce1b263 applayerprotocols/httpservice/src/CConnectionMonitor.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/applayerprotocols/httpservice/src/CConnectionMonitor.cpp Thu May 27 13:21:53 2010 +0300 @@ -0,0 +1,141 @@ +// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// +#include +#include +#include "CConnectionMonitor.h" +#include "chttpnetworkconnectioninfo.h" + +CConnectionMonitor* CConnectionMonitor::NewL(CHttpNetworkConnection* aNetworkConn ) + { + CConnectionMonitor* self = NewLC( aNetworkConn ); + CleanupStack::Pop( self ); + return self; + } + +CConnectionMonitor* CConnectionMonitor::NewLC( CHttpNetworkConnection* aNetworkConn ) + { + CConnectionMonitor* self = new (ELeave) CConnectionMonitor( aNetworkConn ); + CleanupStack::PushL( self ); + self->ConstructL(); + return self; + } + +CConnectionMonitor::CConnectionMonitor( CHttpNetworkConnection* aNetworkConnInfo ) +: CActive(CActive::EPriorityStandard) + { + iNetworkConnInfo = aNetworkConnInfo; + CActiveScheduler::Add(this); + } + +CConnectionMonitor::~CConnectionMonitor() + { + Cancel(); + } + +RConnection CConnectionMonitor::Connection() + { + return iNetworkConnInfo->Connection(); + } + +void CConnectionMonitor::ConstructL() + { + iNetworkConnInfo->Connection().ProgressNotification(iProgress, iStatus); + SetActive(); + } + +void CConnectionMonitor::DoCancel() + { + iNetworkConnInfo->Connection().CancelProgressNotification(); + } + +void CConnectionMonitor::RunL() + { + + + switch ( iProgress().iStage ) + { + + // Connection closed + case KConnectionClosed: + case KLinkLayerClosed: + if (iNetworkConnInfo) + { + iNetworkConnInfo->HandleConnectionEvent( iProgress().iStage ); + } + break; + + case KConnectionUninitialised: + break; + + case KStartingSelection: + break; + + case KFinishedSelection: + if (iProgress().iError == KErrNone) + { + // The user successfully selected an IAP to be used + } + else + { + // The user pressed e.g. "Cancel" and did not select an IAP + } + break; + + case KConnectionFailure: + break; + + // Prepearing connection (e.g. dialing) + case KPsdStartingConfiguration: + case KPsdFinishedConfiguration: + case KCsdFinishedDialling: + case KCsdScanningScript: + case KCsdGettingLoginInfo: + case KCsdGotLoginInfo: + break; + + // Creating connection (e.g. GPRS activation) + case KCsdStartingConnect: + case KCsdFinishedConnect: + break; + + // Starting log in + case KCsdStartingLogIn: + break; + + // Finished login + case KCsdFinishedLogIn: + break; + + // Connection open + case KConnectionOpen: + case KLinkLayerOpen: + break; + + // Connection blocked or suspended + case KDataTransferTemporarilyBlocked: + break; + + // Hangup or GRPS deactivation + case KConnectionStartingClose: + break; + + // Unhandled state + default: + break; + } + + Connection().ProgressNotification(iProgress, iStatus); + SetActive(); + } diff -r cb0c8a2aff2d -r 2f328ce1b263 applayerprotocols/httpservice/src/chttpclientauthentication.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/applayerprotocols/httpservice/src/chttpclientauthentication.cpp Thu May 27 13:21:53 2010 +0300 @@ -0,0 +1,62 @@ +// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#include "chttpclientauthentication.h" +#include "mhttpserviceauthentication.h" + +CHttpClientAuthentication* CHttpClientAuthentication::New(RHTTPSession aSesion, MHTTPServiceAuthentication* aCallback) + { + CHttpClientAuthentication* self = new CHttpClientAuthentication; + TInt err = self->Construct(aSesion, aCallback); + if(err != KErrNone) + { + delete self; + self = NULL; + } + return self; + } + +TInt CHttpClientAuthentication::Construct(RHTTPSession aSession, MHTTPServiceAuthentication* aCallback) + { + // Install this class as the callback for authentication requests + TRAPD(err, InstallAuthenticationL(aSession)); + iHTTPServiceAuthentication = aCallback; + return err; + } + +void CHttpClientAuthentication::FillCredentialsL(RString& aRealm, RString& aUsername, RString& aPassword, RBuf8& aClientUsername, RBuf8& aClientPassword) + { + aUsername = aRealm.Pool().OpenStringL(aClientUsername); + aPassword = aRealm.Pool().OpenStringL(aClientPassword); + } + +TBool CHttpClientAuthentication::GetCredentialsL(const TUriC8& aURI, RString aRealm, + RStringF aAuthenticationType, + RString& aUsername, + RString& aPassword) + { + //User credentials + RBuf8 clientUsername; + RBuf8 clientPassword; + + User::LeaveIfError(iHTTPServiceAuthentication->OnAuthentication(aURI.UriDes(), aRealm.DesC(), aAuthenticationType.DesC(), clientUsername, clientPassword)); + + FillCredentialsL(aRealm, aUsername, aPassword, clientUsername, clientPassword); + + clientUsername.Close(); + clientPassword.Close(); + + return ETrue; + } diff -r cb0c8a2aff2d -r 2f328ce1b263 applayerprotocols/httpservice/src/chttpnetworkconnectioninfo.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/applayerprotocols/httpservice/src/chttpnetworkconnectioninfo.cpp Thu May 27 13:21:53 2010 +0300 @@ -0,0 +1,204 @@ +// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// +#include +#include +#include "CConnectionMonitor.h" + + +CHttpNetworkConnection::CHttpNetworkConnection() + { + } + +CHttpNetworkConnection::~CHttpNetworkConnection() + { + if (iConnInfo) + { + iConnInfo->iConnection.Close(); + iConnInfo->iSocketServ.Close(); + delete iConnInfo; + } + if (iConnectionMonitor) + { + delete iConnectionMonitor; + } + } +CHttpNetworkConnection* CHttpNetworkConnection::New( ) + { + CHttpNetworkConnection* self = new (ELeave) CHttpNetworkConnection() ; + self->ConstructL(); + return self; + } + +void CHttpNetworkConnection::ConstructL() + { + iConnInfo = new (ELeave) CConnectionInfo(); + } + +void CHttpNetworkConnection::SetHttpService(CHttpService *aService) + { + iHttpService = aService; + } + +/** + * Start the network connection for HTTP transactions. + * Default connection prefernces will be used. + * + * @return KErrNone if connection opening is successful, otherwise relevant errors. + */ +EXPORT_C TInt CHttpNetworkConnection::Start() + { + TRequestStatus requestStatus; + TInt status; + if (! iConnInfo->iConnectionStatus) + { + status = SetupConnection(); + if (status == KErrNone) + { + iConnInfo->iConnection.Start( requestStatus); + User::WaitForRequest(requestStatus); + status = requestStatus.Int(); + } + } + else + { + status = KErrAlreadyExists; + } + if (status == KErrNone) + { + AssociateConnectionWithHttpSession(); + } + return status; + } + +/** + * Start the network connection for HTTP transactions. + * + * @param aConnPref - connection prefernces can be specified. + * @param aAttachType - EFalse + * + * @return KErrNoMemory incase of failure otherwise KErrNone for success + * + */ +EXPORT_C TInt CHttpNetworkConnection::Start(TCommDbConnPref aConnPref, TBool aAttachType) + { + TInt status; + iConnInfo->iConnPref = aConnPref; + + if (aAttachType && !iConnInfo->iConnectionStatus ) + { + TUint count; + TConnectionInfoBuf connInfoPckg; + + status = SetupConnection(); + + if ( status == KErrNone && iConnInfo->iConnection.EnumerateConnections(count) == KErrNone ) + { + for (TUint i=1; i<=count; i++) + { + // Note GetConnectionInfo expects 1-based index + if ( iConnInfo->iConnection.GetConnectionInfo( i, connInfoPckg ) == KErrNone ) + { + if ( connInfoPckg().iIapId == iConnInfo->iConnPref.IapId() ) + { + status= iConnInfo->iConnection.Attach(iConnInfo->iConnPref, RConnection::EAttachTypeNormal); + return status; + } + } + } + } + return KErrNotFound; + } + else + { + if (!iConnInfo->iConnectionStatus) + { + status = SetupConnection(); + if (status == KErrNone) + { + TRequestStatus requestStatus; + iConnInfo->iConnection.Start(iConnInfo->iConnPref,requestStatus); + User::WaitForRequest(requestStatus); + status = requestStatus.Int(); + } + + } + else + { + status = KErrAlreadyExists; + } + if (status == KErrNone) + { + AssociateConnectionWithHttpSession(); + } + + return status; + } + } + + +/** + * To Stop the network connection + * + */ +EXPORT_C void CHttpNetworkConnection::Stop() + { + if (iConnInfo->iConnectionStatus) + { + iConnInfo->iConnectionStatus = EFalse; + iConnInfo->iConnection.Close(); + iConnInfo->iSocketServ.Close(); + } + } + +void CHttpNetworkConnection::AssociateConnectionWithHttpSession() + { + RStringPool strP = iHttpService->Session().StringPool(); + RHTTPConnectionInfo connInfo = iHttpService->Session().ConnectionInfo(); + connInfo.SetProperty(strP.StringF(HTTP::EHttpSocketServ,RHTTPSession::GetTable()), THTTPHdrVal(iConnInfo->iSocketServ.Handle())); + TInt connPtr = reinterpret_cast(&(iConnInfo->iConnection)); + connInfo.SetProperty(strP.StringF(HTTP::EHttpSocketConnection,RHTTPSession::GetTable()), THTTPHdrVal(connPtr)); + } + +TInt CHttpNetworkConnection::SetupConnection() + { + TInt status = KErrAlreadyExists; + if (!iConnInfo->iConnectionStatus ) + { + status = iConnInfo->iSocketServ.Connect() ; + if (status == KErrNone) + { + status = iConnInfo->iConnection.Open ( iConnInfo->iSocketServ ) ; + if (status != KErrNone) + { + iConnInfo->iSocketServ.Close(); + } + else + { + iConnectionMonitor = CConnectionMonitor::NewL(this); + iConnInfo->iConnectionStatus = ETrue; + } + } + } + return status; + } + +void CHttpNetworkConnection::HandleConnectionEvent(TInt aError) + { + if (aError == KLinkLayerClosed || aError == KLinkLayerClosed) + { + iConnInfo->iConnectionStatus = EFalse; + } + } + diff -r cb0c8a2aff2d -r 2f328ce1b263 applayerprotocols/httpservice/src/chttpservice.cpp --- a/applayerprotocols/httpservice/src/chttpservice.cpp Fri May 14 16:23:37 2010 +0300 +++ b/applayerprotocols/httpservice/src/chttpservice.cpp Thu May 27 13:21:53 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -15,7 +15,9 @@ #include "chttpservice.h" #include "httpclientutils.h" - +#include "chttpclientauthentication.h" +#include "mhttpserviceauthentication.h" +#include "chttpnetworkconnectioninfo.h" const TInt KMaxNoOfConnections = 6; const TInt KMaxTransToPipeline = 5; @@ -45,6 +47,14 @@ } /** + * Destructor of the inner class CHttpServiceStruct + */ +CHttpService::CHttpServiceStruct::~CHttpServiceStruct() + { + delete iHttpClientAuthentication; + } + +/** * Retrieves the equivalent string for a give string ID from the * HTTP string pool * @@ -212,6 +222,15 @@ return err; } +EXPORT_C TInt CHttpService::SetAuthentication(MHTTPServiceAuthentication* aCallback) + { + TInt error = KErrGeneral; + iHttpServiceStruct->iHttpClientAuthentication = CHttpClientAuthentication::New(iHttpServiceStruct->iHttpSession, aCallback); + if(iHttpServiceStruct->iHttpClientAuthentication) + error = KErrNone; + return error; + } + /** * Constructor */ @@ -229,3 +248,9 @@ SetMaxTransactionsToPipeline(KMaxTransToPipeline); } +EXPORT_C CHttpNetworkConnection* CHttpService::HttpNetworkConnection() + { + CHttpNetworkConnection *httpNetworkConn = CHttpNetworkConnection::New(); + httpNetworkConn->SetHttpService(this); + return httpNetworkConn; + } diff -r cb0c8a2aff2d -r 2f328ce1b263 applayerprotocols/httpservice/test/group/httpservicetest.mmp --- a/applayerprotocols/httpservice/test/group/httpservicetest.mmp Fri May 14 16:23:37 2010 +0300 +++ b/applayerprotocols/httpservice/test/group/httpservicetest.mmp Thu May 27 13:21:53 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -31,7 +31,7 @@ SOURCE ctestclienthttpget.cpp SOURCE ctestclienthttppost.cpp SOURCE ctesthttpclientstep.cpp -SOURCE chttpclienttestparams.cpp +SOURCE chttpclienttestparams.cpp ctesthttpserviceauthentication.cpp USERINCLUDE ../../inc USERINCLUDE ../../../httptransportfw/test/t_utils @@ -59,5 +59,5 @@ LIBRARY efsrv.lib LIBRARY httptestutils.lib LIBRARY esock.lib insock.lib - +LIBRARY commdb.lib SMPSAFE diff -r cb0c8a2aff2d -r 2f328ce1b263 applayerprotocols/httpservice/test/httpservicetest/chttpclienttestparams.cpp --- a/applayerprotocols/httpservice/test/httpservicetest/chttpclienttestparams.cpp Fri May 14 16:23:37 2010 +0300 +++ b/applayerprotocols/httpservice/test/httpservicetest/chttpclienttestparams.cpp Thu May 27 13:21:53 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -23,6 +23,8 @@ _LIT(KUri, "Uri"); _LIT(KRawRequest, "RawRequest"); _LIT(KRawResponse, "RawResponse"); +_LIT(KRawEncodedAuthenticationRequest, "RawEncodedAuthenticationRequest"); +_LIT(KRawFinalResponse, "RawFinalResponse"); _LIT(KResponseBody, "ResponseBody"); _LIT(KStatusCode, "StatusCode"); _LIT(KResponseFieldCount, "ResponseFieldCount"); @@ -58,7 +60,8 @@ _LIT(KProxyAddress, "ProxyAddress"); _LIT(KResponseTimeout, "ResponseTimeout"); _LIT(KRedirection, "Redirection"); -_LIT(KNotifyTransferProgress, "NotifyTransferProgress"); +_LIT(KNotifyTransferProgress, "NotifyTransferProgress"); +_LIT(KSetAuthentication, "SetAuthentication"); _LIT8(KScriptLF8, "\\n"); _LIT8(KReplaceLF8, "\n"); @@ -107,6 +110,8 @@ TPtrC uri; TPtrC rawRequest; TPtrC rawResponse; + TPtrC rawEncodedAuthenticationRequest; + TPtrC rawFinalResponse; if(!aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), KMethod(), method) || !aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), KUri(), uri) || !aTestCase.GetIntFromConfig(aTestCase.ConfigSection(), KStatusCode(), iStatusCode)) @@ -115,13 +120,21 @@ } aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), KRawRequest(), rawRequest); aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), KRawResponse(), rawResponse); + aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), KRawEncodedAuthenticationRequest(), rawEncodedAuthenticationRequest); + aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), KRawFinalResponse(), rawFinalResponse); iMethod = EscapeUtils::ConvertFromUnicodeToUtf8L(method); iUri = EscapeUtils::ConvertFromUnicodeToUtf8L(uri); iRawRequest = EscapeUtils::ConvertFromUnicodeToUtf8L(rawRequest); iRawResponse = EscapeUtils::ConvertFromUnicodeToUtf8L(rawResponse); + iEncodedAuthenticationRequest = EscapeUtils::ConvertFromUnicodeToUtf8L(rawEncodedAuthenticationRequest); + iFinalResponse = EscapeUtils::ConvertFromUnicodeToUtf8L(rawFinalResponse); + ParseAndReplaceCRLF(iRawRequest); ParseAndReplaceCRLF(iRawResponse); + ParseAndReplaceCRLF(iEncodedAuthenticationRequest); + ParseAndReplaceCRLF(iFinalResponse); + TPtrC responseBody; @@ -321,6 +334,9 @@ iNotifyTransferProgress = EFalse; aTestCase.GetBoolFromConfig(aTestCase.ConfigSection(), KNotifyTransferProgress(), iNotifyTransferProgress); + iSetAuthentication = EFalse; + aTestCase.GetBoolFromConfig(aTestCase.ConfigSection(), KSetAuthentication(), iSetAuthentication); + TPtrC proxyAddress; if(aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), KProxyAddress, proxyAddress)) { @@ -335,6 +351,8 @@ delete iMethod; delete iUri; delete iRawRequest; + delete iEncodedAuthenticationRequest; + delete iFinalResponse; delete iRawResponse; delete iResponseBody; iResponseHeaderInfos.ResetAndDestroy(); @@ -365,6 +383,30 @@ return *iRawResponse; } +const TDesC8& CHttpClientTestParams::EncodedAuthenticationRequest() const + { + return *iEncodedAuthenticationRequest; + } + +void CHttpClientTestParams::SetAuthReqRes() + { + if (iRawRequest) + { + delete iRawRequest; + iRawRequest = NULL; + } + if (iRawResponse) + { + delete iRawResponse; + iRawResponse = NULL; + } + iRawRequest = iEncodedAuthenticationRequest; + iRawResponse = iFinalResponse; + + iEncodedAuthenticationRequest = NULL; + iFinalResponse = NULL; + } + const TDesC8& CHttpClientTestParams::ResponseBody() const { if(iResponseBody) @@ -432,6 +474,11 @@ return iNotifyTransferProgress; } +TBool CHttpClientTestParams::IsAuthenticationReqd() const + { + return iSetAuthentication; + } + TBool CHttpClientTestParams::CheckVariantValue(const THttpHeaderValueVariant& aVariant, const TDesC8& aValueToMatch) { TBool ret = EFalse; diff -r cb0c8a2aff2d -r 2f328ce1b263 applayerprotocols/httpservice/test/httpservicetest/chttpclienttestparams.h --- a/applayerprotocols/httpservice/test/httpservicetest/chttpclienttestparams.h Fri May 14 16:23:37 2010 +0300 +++ b/applayerprotocols/httpservice/test/httpservicetest/chttpclienttestparams.h Thu May 27 13:21:53 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -122,6 +122,8 @@ const TDesC8& Uri() const; const TDesC8& RawRequest() const; const TDesC8& RawResponse() const; + const TDesC8& EncodedAuthenticationRequest() const; + void SetAuthReqRes(); const TDesC8& ResponseBody() const; const RPointerArray& HeaderInfos() const { @@ -151,6 +153,7 @@ TBool ResponseTimeoutEnable() const; TBool IsRedirecting() const; TBool TransferProgress() const; + TBool IsAuthenticationReqd() const; const TDesC8& RequestBody() const { @@ -194,6 +197,8 @@ HBufC8* iUri; HBufC8* iRawRequest; HBufC8* iRawResponse; + HBufC8* iEncodedAuthenticationRequest; + HBufC8* iFinalResponse; HBufC8* iResponseBody; HBufC8* iRequestBody; TInt iExpectedError; @@ -205,6 +210,7 @@ TBool iResponseTimeout; TBool iRedirection; TBool iNotifyTransferProgress; + TBool iSetAuthentication; HBufC8* iProxyAddress; }; diff -r cb0c8a2aff2d -r 2f328ce1b263 applayerprotocols/httpservice/test/httpservicetest/ctesthttpclientstep.cpp --- a/applayerprotocols/httpservice/test/httpservicetest/ctesthttpclientstep.cpp Fri May 14 16:23:37 2010 +0300 +++ b/applayerprotocols/httpservice/test/httpservicetest/ctesthttpclientstep.cpp Thu May 27 13:21:53 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -19,9 +19,12 @@ #include "ctestclienthttppost.h" #include #include +#include #include "httptestutils.h" #include "clocaltestserver.h" #include "chttpclienttestparams.h" +#include "ctesthttpserviceauthentication.h" +#include "chttpnetworkconnectioninfo.h" _LIT(KTestCaseName, "TestCaseName"); _LIT8(KUserAgent, "HTTP Client API Test"); @@ -43,19 +46,27 @@ delete iTestUtils; delete iTestParamArray; delete iActiveScheduler; + delete iTestHttpServiceAuthentication; } // TEF virtuals TVerdict CTestHttpClientStep::doTestStepPreambleL() { + TInt status; iActiveScheduler = new (ELeave) CActiveScheduler(); CActiveScheduler::Install(iActiveScheduler); iTestParamArray = new(ELeave) CHttpClientTestParamArray; iTestUtils = CHTTPTestUtils::NewL(KTestHttpClientAPITestTitle()); - iTestUtils->InitCommsL(); + iTestServer = CLocalTestServer::NewL(*iTestUtils, *this, *iTestParamArray); iHttpClient = CHttpService::NewL(); + TCommDbConnPref connPref; + connPref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt); + connPref.SetIapId(1); + connPref.SetNetId(0); + iHttpConnInfo = iHttpClient->HttpNetworkConnection(); + status = iHttpConnInfo->Start(); THttpHeaderValueVariant variant(KUserAgent()); if(iHttpClient->AddRequestHeader(HTTP::EUserAgent, variant)) { @@ -99,6 +110,12 @@ } } + if(param->IsAuthenticationReqd()) + { + iTestHttpServiceAuthentication = new CTestHttpServiceAuthentication(); + User::LeaveIfError(iHttpClient->SetAuthentication(iTestHttpServiceAuthentication)); + } + if(param->Method().CompareF(KGetMethod) == 0) { if(param->OnlineTest()) @@ -126,12 +143,10 @@ { iHttpTrans->SetNoRetry(); } - if(param->ResponseTimeoutEnable()) { iHttpTrans->SetResponseTimeout(10); } - const RPointerArray& info = param->RequestHeaderInfos(); for(TInt i = 0; i < info.Count(); ++i) { @@ -161,7 +176,7 @@ THTTPHdrVal::TQConv q(value); TInt val2 = q; THttpHeaderValueVariant variant2(val2); - // Set the header with the param + /// Set the header with the param iHttpTrans->AddRequestHeader(headerName, variant, paramName, variant2); } } diff -r cb0c8a2aff2d -r 2f328ce1b263 applayerprotocols/httpservice/test/httpservicetest/ctesthttpclientstep.h --- a/applayerprotocols/httpservice/test/httpservicetest/ctesthttpclientstep.h Fri May 14 16:23:37 2010 +0300 +++ b/applayerprotocols/httpservice/test/httpservicetest/ctesthttpclientstep.h Thu May 27 13:21:53 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -26,6 +26,8 @@ class CLocalTestServer; class CHTTPTestUtils; class CHttpClientTestParamArray; +class CHttpNetworkConnection; +class CTestHttpServiceAuthentication; class CTestHttpClientStep : public CTestStep, public MLocalTestServerObserver { @@ -48,6 +50,8 @@ CHTTPTestUtils* iTestUtils; CLocalTestServer* iTestServer; CHttpClientTestParamArray* iTestParamArray; + CTestHttpServiceAuthentication* iTestHttpServiceAuthentication; + CHttpNetworkConnection* iHttpConnInfo; }; #endif // __CTESTHTTPCLIENTSTEP_H__ diff -r cb0c8a2aff2d -r 2f328ce1b263 applayerprotocols/httpservice/test/httpservicetest/ctesthttpserviceauthentication.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/applayerprotocols/httpservice/test/httpservicetest/ctesthttpserviceauthentication.cpp Thu May 27 13:21:53 2010 +0300 @@ -0,0 +1,42 @@ +// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// +#include +#include +#include "ctesthttpserviceauthentication.h" + +_LIT(KAuthURL, "Passing credentials for URL %S, realm %S\n"); +_LIT(KAuthType, "Using %S authentication\n"); + +CTestHttpServiceAuthentication::~CTestHttpServiceAuthentication() + { + } + +CTestHttpServiceAuthentication::CTestHttpServiceAuthentication() + { + } + + +// From MHTTPServiceAuthentication +TInt CTestHttpServiceAuthentication::OnAuthentication(const TDesC8& /*aUri*/, const TDesC8& /*aRealm*/, const TDesC8& /*aType*/, RBuf8& aUsername, RBuf8& aPassword) + { + //User credentials + _LIT8(KUserName, "username"); + _LIT8(KPassword, "password"); + + aUsername.Create(KUserName); + aPassword.Create(KPassword); + return KErrNone; + } + diff -r cb0c8a2aff2d -r 2f328ce1b263 applayerprotocols/httpservice/test/httpservicetest/ctesthttpserviceauthentication.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/applayerprotocols/httpservice/test/httpservicetest/ctesthttpserviceauthentication.h Thu May 27 13:21:53 2010 +0300 @@ -0,0 +1,35 @@ +// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#ifndef __CTESTHTTPSERVICEAUTHENTICATION_H__ +#define __CTESTHTTPSERVICEAUTHENTICATION_H__ + +#include +#include "mhttpserviceauthentication.h" + +class CTestHttpServiceAuthentication : public CBase, public MHTTPServiceAuthentication + { +public: + CTestHttpServiceAuthentication(); + ~CTestHttpServiceAuthentication(); + + // inherited from MHTTPServiceAuthentication + TInt OnAuthentication(const TDesC8& aUri, const TDesC8& aRealm, const TDesC8& aType, RBuf8& aUsername, RBuf8& aPassword); + +private: + + }; + +#endif // __CTESTHTTPSERVICEAUTHENTICATION_H__ diff -r cb0c8a2aff2d -r 2f328ce1b263 applayerprotocols/httpservice/test/testdata/ini/httpclient.ini --- a/applayerprotocols/httpservice/test/testdata/ini/httpclient.ini Fri May 14 16:23:37 2010 +0300 +++ b/applayerprotocols/httpservice/test/testdata/ini/httpclient.ini Thu May 27 13:21:53 2010 +0300 @@ -331,6 +331,23 @@ RequestFileName= C:\HttpTest\httpservicetest\testdl2.txt RequestFileNameStore= C:\HttpTest\httpservicetest\testulstore3.txt +[TEST20] +TestCaseName= "HTTP CLIENT API GET17" +Method=GET +Uri= http://127.0.0.1/index19.html +RawRequest= GET /index19.html HTTP/1.1\r\nHost: 127.0.0.1\r\nUser-Agent: HTTP Client API Test\r\n\r\n +RawResponse= HTTP/1.1 401 Authorization Required\r\nContent-Length: 0\r\nWWW-Authenticate: Basic realm=\r\r"Something"\r\n\r\n +RawEncodedAuthenticationRequest= GET /index19.html HTTP/1.1\r\nHost: 127.0.0.1\r\nAuthorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=\r\nUser-Agent: HTTP Client API Test\r\n\r\n +RawFinalResponse= HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: 0\r\n\r\n +StatusCode= 200 +ResponseFieldCount= 2 +ResponseHeader1= Content-Length +ResponseHeader1ValueCount= 1 +ResponseHeader1.Value1= 0 +ResponseHeader2= Content-Type +ResponseHeader2ValueCount= 1 +ResponseHeader2.Value1= text/plain +SetAuthentication= ETrue [#Done] diff -r cb0c8a2aff2d -r 2f328ce1b263 applayerprotocols/httpservice/test/testdata/scripts/httpserviceapitest.script --- a/applayerprotocols/httpservice/test/testdata/scripts/httpserviceapitest.script Fri May 14 16:23:37 2010 +0300 +++ b/applayerprotocols/httpservice/test/testdata/scripts/httpserviceapitest.script Thu May 27 13:21:53 2010 +0300 @@ -1,5 +1,5 @@ // -// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -134,6 +134,11 @@ RUN_TEST_STEP 600 httpserviceapitest httpserviceapiteststep C:\HttpTest\httpservicetest\httpclient.ini TEST19 END_TESTCASE APPPROT-HTTP-SERVICE-API-00019 +START_TESTCASE APPPROT-HTTP-SERVICE-API-00020 +RUN_TEST_STEP 600 httpserviceapitest httpserviceapiteststep C:\HttpTest\httpservicetest\httpclient.ini TEST20 +END_TESTCASE APPPROT-HTTP-SERVICE-API-00020 + + PRINT Finishing_HTTP_Service_API_Test diff -r cb0c8a2aff2d -r 2f328ce1b263 applayerprotocols/httptransportfw/Test/EABI/httptestutilsU.def --- a/applayerprotocols/httptransportfw/Test/EABI/httptestutilsU.def Fri May 14 16:23:37 2010 +0300 +++ b/applayerprotocols/httptransportfw/Test/EABI/httptestutilsU.def Thu May 27 13:21:53 2010 +0300 @@ -126,5 +126,4 @@ _ZN14CHTTPTestUtils23CleanupFailedTestsArrayEv @ 125 NONAME _ZN14CHTTPTestUtils23CreateFailedTestsArrayLEv @ 126 NONAME _ZN11CScriptFile7SectionERK7TDesC16 @ 127 NONAME - _ZZN14CHTTPTestUtils8OverflowER6TDes16E15KErrOverflowMsg @ 128 NONAME DATA 12 - + \ No newline at end of file diff -r cb0c8a2aff2d -r 2f328ce1b263 httpfilters/cookie/ManagerSrc/CookieIPC.cpp --- a/httpfilters/cookie/ManagerSrc/CookieIPC.cpp Fri May 14 16:23:37 2010 +0300 +++ b/httpfilters/cookie/ManagerSrc/CookieIPC.cpp Thu May 27 13:21:53 2010 +0300 @@ -526,7 +526,11 @@ while ( bufferPtr < bufferEndPtr ) { + // coverity [alloc_fn] + // coverity [assign] CCookie* cookie = CCookie::NewL( iStringPool ); + + // coverity [push] CleanupStack::PushL( cookie ); UnpackCookieL( bufferPtr, *cookie ); @@ -540,9 +544,11 @@ // The cookie pointer array (i.e. iCookies) takes over the // ownership User::LeaveIfError( aCookies.Append( cookie ) ); - + + // coverity [pop] CleanupStack::Pop(); // cookie } + // coverity [memory_leak] } } diff -r cb0c8a2aff2d -r 2f328ce1b263 httpfilters/httpfilteracceptheader/Src/HttpFilterAcceptHeader.cpp --- a/httpfilters/httpfilteracceptheader/Src/HttpFilterAcceptHeader.cpp Fri May 14 16:23:37 2010 +0300 +++ b/httpfilters/httpfilteracceptheader/Src/HttpFilterAcceptHeader.cpp Thu May 27 13:21:53 2010 +0300 @@ -551,8 +551,12 @@ // Declare a language arrays CArrayFixFlat* systemEpocLanguageCodes = 0; - // Get installed language codes - User::LeaveIfError( SysLangUtil::GetInstalledLanguages(systemEpocLanguageCodes) ); + // Get installed language codes + // coverity [alloc_fn] + // coverity [freed_arg] + User::LeaveIfError( SysLangUtil::GetInstalledLanguages(systemEpocLanguageCodes) ); + + // coverity [double_free] CleanupStack::PushL( systemEpocLanguageCodes ); // Compose the String such as "en;q=1.0, es;q=0.5, fr;q=0.5" diff -r cb0c8a2aff2d -r 2f328ce1b263 httpfilters/httpfilterauthentication/Src/HttpFilterAuthentication.cpp --- a/httpfilters/httpfilterauthentication/Src/HttpFilterAuthentication.cpp Fri May 14 16:23:37 2010 +0300 +++ b/httpfilters/httpfilterauthentication/Src/HttpFilterAuthentication.cpp Thu May 27 13:21:53 2010 +0300 @@ -656,7 +656,8 @@ { THTTPHdrVal fieldVal; // The name of the current field. THTTPHdrVal hdrVal; //A scratch hdrVal - // coverity [CHECKED_RETURN] + // coverity [check_return] + // coverity [unchecked_value] headers.GetField( wwwAuthenticate, ii, fieldVal ); switch ( fieldVal.StrF().Index( RHTTPSession::GetTable() ) ) diff -r cb0c8a2aff2d -r 2f328ce1b263 httpfilters/httpfilterauthentication/Src/HttpFilterDigestAuthentication.cpp --- a/httpfilters/httpfilterauthentication/Src/HttpFilterDigestAuthentication.cpp Fri May 14 16:23:37 2010 +0300 +++ b/httpfilters/httpfilterauthentication/Src/HttpFilterDigestAuthentication.cpp Thu May 27 13:21:53 2010 +0300 @@ -508,8 +508,10 @@ { THTTPHdrVal fieldVal; // The name of the current field. THTTPHdrVal hdrVal; //A scratch hdrVal - // coverity [CHECKED_RETURN] - headers.GetField( wwwAuthenticate, ii, fieldVal ); + + // coverity [check_return] + // coverity [unchecked_value] + headers.GetField( wwwAuthenticate, ii, fieldVal ); switch ( fieldVal.StrF().Index( RHTTPSession::GetTable() ) ) {