applayerprotocols/httptransportfw/Test/T_HttpPipeliningTest/CTestCase22.cpp
changeset 0 b16258d2340f
equal deleted inserted replaced
-1:000000000000 0:b16258d2340f
       
     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 #include "CTestCase22.h"
       
    17 #include "httptestutils.h"
       
    18 
       
    19 const TInt KTransactionCount = 1;
       
    20 const TInt KConnectionCount = 1;
       
    21 
       
    22 _LIT8(KTxtRawRequest, "GET / HTTP/1.1\r\nHost: 127.0.0.1\r\n\r\n");
       
    23 _LIT8(KTxtRawResponse, "HTTP/1.1 200 Ok\r\nContent-Length: 6\r\nX-Oma-Drm-Separate-Delivery: \r\n\r\nhello!");
       
    24 _LIT8(KCustomField, "X-Oma-Drm-Separate-Delivery");
       
    25 
       
    26 CTestCase22* CTestCase22::NewL(CHTTPTestUtils& aTestUtils)
       
    27 	{
       
    28 	CTestCase22* self = new (ELeave) CTestCase22(aTestUtils);
       
    29 	CleanupStack::PushL(self);
       
    30 	self->ConstructL();
       
    31 	CleanupStack::Pop(self);
       
    32 	return self;
       
    33 	}
       
    34 
       
    35 CTestCase22::CTestCase22(CHTTPTestUtils& aTestUtils)
       
    36 : CPipeliningTestCase(), iTestUtils(aTestUtils)
       
    37 	{
       
    38 	}
       
    39 
       
    40 void CTestCase22::ConstructL()
       
    41 	{
       
    42 	}
       
    43 
       
    44 CTestCase22::~CTestCase22()
       
    45 	{
       
    46 	}
       
    47 
       
    48 const TDesC& CTestCase22::TestCaseName() const
       
    49 	{
       
    50 	_LIT(KTxtTitle, "Test Case 22");
       
    51 	return KTxtTitle();
       
    52 	}
       
    53 
       
    54 TInt CTestCase22::TotalTransactionCount() const
       
    55 	{
       
    56 	return KTransactionCount;
       
    57 	}
       
    58 	
       
    59 TInt CTestCase22::ConnectionCount() const
       
    60 	{
       
    61 	return KConnectionCount;
       
    62 	}
       
    63 	
       
    64 RHTTPTransaction CTestCase22::GetTransactionL(TInt aIndex, RHTTPSession aSession, MHTTPTransactionCallback& aClient)
       
    65 	{
       
    66 	__ASSERT_ALWAYS(aIndex<KTransactionCount, User::Invariant());
       
    67 	
       
    68 	RStringF method = aSession.StringPool().StringF(HTTP::EGET,RHTTPSession::GetTable());
       
    69 	_LIT8(KTxtUri, "http://127.0.0.1");
       
    70 	TUriParser8 uri; 
       
    71 	uri.Parse(KTxtUri());
       
    72 	return aSession.OpenTransactionL(uri, aClient, method);
       
    73 	}
       
    74 
       
    75 const TDesC8& CTestCase22::GetRawRequest(TInt aConnectionIndex, TInt aTransIndex)
       
    76 	{
       
    77 	__ASSERT_ALWAYS( (aTransIndex<KTransactionCount) && (aConnectionIndex < KConnectionCount), User::Invariant());
       
    78 	
       
    79 	return KTxtRawRequest();
       
    80 	}
       
    81 	
       
    82 const TDesC8& CTestCase22::GetRawResponse(TInt aConnectionIndex, TInt aTransIndex)
       
    83 	{
       
    84 	__ASSERT_ALWAYS( (aTransIndex<KTransactionCount) && (aConnectionIndex < KConnectionCount), User::Invariant());
       
    85 
       
    86 	return KTxtRawResponse();
       
    87 	}
       
    88 
       
    89 void CTestCase22::ProcessHeadersL(RHTTPTransaction aTrans)
       
    90 	{
       
    91 	RHTTPResponse resp = aTrans.Response();
       
    92 	TInt status = resp.StatusCode();
       
    93 	
       
    94 	RStringF headerName = aTrans.Session().StringPool().OpenFStringL(KCustomField);
       
    95 	CleanupClosePushL(headerName);
       
    96 
       
    97 	THTTPHdrVal headerVal;
       
    98 	RHTTPHeaders headers = aTrans.Response().GetHeaderCollection();
       
    99 	TPtrC8 rawValue;
       
   100 	headers.GetRawField(headerName,rawValue);
       
   101 	
       
   102 	TPtrC8 hdrVal(KNullDesC8);
       
   103 	if(rawValue.Compare(hdrVal) != 0)
       
   104 		{
       
   105 		iTestUtils.LogIt ( _L("\nTesting custom header NULL value failed.") );	
       
   106 		User::Leave(KErrArgument);
       
   107 		}
       
   108 	iTestUtils.LogIt ( _L("\nTesting custom header NULL value Passed.") );
       
   109 	CleanupStack::PopAndDestroy(&headerName);
       
   110 	}
       
   111 
       
   112