applayerprotocols/httptransportfw/Test/Acceptance/Iter2/post12.cpp
changeset 0 b16258d2340f
equal deleted inserted replaced
-1:000000000000 0:b16258d2340f
       
     1 // Copyright (c) 2004-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 #include "post12.h"
       
    17 #include <http.h>
       
    18 
       
    19 #include "csrvaddrval.h"
       
    20 
       
    21 _LIT8(KWapTestUrl,			"http://WapTestIP");
       
    22 
       
    23 CHttpTestCasePost12::CHttpTestCasePost12(CScriptFile* aIniSettingsFile) 
       
    24 	:	CHttpAcceptTestBase(),
       
    25 		iIniSettingsFile(aIniSettingsFile)
       
    26 	{
       
    27 	}
       
    28 
       
    29 const TDesC& CHttpTestCasePost12::TestName()
       
    30 	{
       
    31 	_LIT(KHeaderTestName,"Iteration 2 Post Test 12 ");
       
    32 	return KHeaderTestName;
       
    33 	}
       
    34 
       
    35 void CHttpTestCasePost12::OpenTestSessionL()
       
    36 	{
       
    37 	//open  a Session
       
    38 	
       
    39 	iSession.OpenL();
       
    40 	iEngine->Utils().LogIt(_L("Session Created(Iteration 2 Post Test 12)"));
       
    41 	iEngine->Utils().LogIt(_L("Session parameters: Default"));
       
    42 
       
    43 	InstallAuthenticationL(iSession);
       
    44 
       
    45 	//Get the iSession'string pool handle;
       
    46 	iMyStrP = iSession.StringPool();
       
    47 	//open string this testcase needs
       
    48 
       
    49 	// Literals used in the function
       
    50 	_LIT8(KUrlPath,				"/perl/protected/dumpform.pl");
       
    51 
       
    52 	// Replace the host name in the URL
       
    53 	HBufC8* newUrl8 = TSrvAddrVal::ReplaceHostNameL(KWapTestUrl(), iIniSettingsFile);
       
    54 	CleanupStack::PushL(newUrl8);
       
    55 	TPtr8 newUrlPtr8 = newUrl8->Des();
       
    56 	newUrlPtr8.Append(KUrlPath());
       
    57 
       
    58 	TUriParser8 testURI;
       
    59 	testURI.Parse(newUrlPtr8);
       
    60 
       
    61 	iTransaction = iSession.OpenTransactionL(testURI, *this, iMyStrP.StringF(HTTP::EPOST,RHTTPSession::GetTable()));
       
    62 	iEngine->Utils().LogIt(_L("Transaction Created in Session"));
       
    63 	iOpenTransactionCount++;
       
    64 
       
    65 	//Get a handle of the request in iTransaction
       
    66 	RHTTPRequest myRequest = iTransaction.Request();
       
    67 	RHTTPHeaders myHeaders = myRequest.GetHeaderCollection();
       
    68 	//provide  some headers 
       
    69 
       
    70 	THTTPHdrVal contentTypeHdr(iMyStrP.StringF(HTTP::EApplicationXWwwFormUrlEncoded,RHTTPSession::GetTable()));
       
    71 	myHeaders.SetFieldL(iMyStrP.StringF(HTTP::EContentType, RHTTPSession::GetTable()),contentTypeHdr);
       
    72 
       
    73 	TSrvAddrVal::LogUsing8BitDesL(iEngine, newUrlPtr8);
       
    74 	iEngine->Utils().LogIt(_L("Method:Post"));
       
    75 	iEngine->Utils().LogIt(_L("Content-Type:application/x-www-form-urlencoded "));
       
    76 	CleanupStack::PopAndDestroy(newUrl8);
       
    77 	myRequest.SetBody(*this);
       
    78 	} 
       
    79 
       
    80 void CHttpTestCasePost12::CloseTestSession()
       
    81 	{
       
    82 	// Close strings used in this session before closing the session
       
    83 	//close Transaction and session
       
    84 	iTransaction.Close();
       
    85 	iEngine->Utils().LogIt(_L("Transaction terminated\n"));
       
    86 	iSession.Close();
       
    87 	iEngine->Utils().LogIt(_L("Session terminated"));
       
    88 	}
       
    89 
       
    90 
       
    91 TBool CHttpTestCasePost12::GetCredentialsL(const TUriC8& aURI, RString aRealm, RStringF aAuthenticationType, RString& aUsername, RString& aPassword)
       
    92 	{
       
    93 	iEngine->Utils().LogIt(_L("Supplying credentials"));
       
    94 	// Can't log 8 bit data, so dump it.
       
    95 	iEngine->Utils().DumpData(aURI.UriDes());
       
    96 	iEngine->Utils().DumpData(aRealm.DesC());	
       
    97 	iEngine->Utils().DumpData(aAuthenticationType.DesC());	
       
    98 	_LIT8(KScooby, "scooby");
       
    99 	_LIT8(KDoo, "doo");
       
   100 	RStringPool p = aRealm.Pool();
       
   101 	aUsername = p.OpenStringL(KScooby);
       
   102 	aPassword = p.OpenStringL(KDoo);
       
   103 	return ETrue;
       
   104 	}