applayerprotocols/httptransportfw/Test/T_HttpPipeliningTest/ctestcase24.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 "ctestcase24.h"
       
    17 #include "httptestutils.h"
       
    18 
       
    19 const TInt KConn1TransCount = 3;
       
    20 const TInt KConn2TransCount = 2;
       
    21 const TInt KConnectionCount = 2;
       
    22 _LIT8(KTxtRawRequest, "GET / HTTP/1.1\r\nHost: 127.0.0.1\r\n\r\n");
       
    23 _LIT8(KTxtRawRequestWithClose, "GET / HTTP/1.1\r\nConnection: Close\r\nHost: 127.0.0.1\r\n\r\n");
       
    24 _LIT8(KTxtRawResponse, "HTTP/1.1 200 Ok\r\nContent-Length: 6\r\n\r\nhello!");
       
    25 
       
    26 
       
    27 CTestCase24* CTestCase24::NewL(CHTTPTestUtils& aTestUtils)
       
    28 	{
       
    29 	CTestCase24* self = new (ELeave) CTestCase24(aTestUtils);
       
    30 	CleanupStack::PushL(self);
       
    31 	self->ConstructL();
       
    32 	CleanupStack::Pop(self);
       
    33 	return self;
       
    34 	}
       
    35 
       
    36 CTestCase24::CTestCase24(CHTTPTestUtils& aTestUtils)
       
    37 : CPipeliningTestCase(), iTestUtils(aTestUtils)
       
    38 	{
       
    39 	}
       
    40 
       
    41 void CTestCase24::ConstructL()
       
    42 	{
       
    43 	}
       
    44 
       
    45 CTestCase24::~CTestCase24()
       
    46 	{
       
    47 	}
       
    48 
       
    49 const TDesC& CTestCase24::TestCaseName() const
       
    50 	{
       
    51 	_LIT(KTxtTitle, "Test Case 24");
       
    52 	return KTxtTitle();
       
    53 	}
       
    54 
       
    55 TInt CTestCase24::TransactionCount(TInt aConnectionIndex) const
       
    56 	{
       
    57 	TInt transCount = 0;
       
    58 	switch(aConnectionIndex)
       
    59 		{
       
    60 		case 0:
       
    61 			{
       
    62 			transCount = KConn1TransCount;
       
    63 			} break;
       
    64 		case 1:
       
    65 			{
       
    66 			transCount = KConn2TransCount;
       
    67 			} break;
       
    68 		default:
       
    69 			User::Invariant();
       
    70 		}
       
    71 
       
    72 	return transCount;
       
    73 	}
       
    74 
       
    75 TInt CTestCase24::TotalTransactionCount() const
       
    76 	{
       
    77 	return KConn1TransCount+KConn2TransCount;
       
    78 	}
       
    79 
       
    80 TInt CTestCase24::ConnectionCount() const
       
    81 	{
       
    82 	return KConnectionCount;
       
    83 	}
       
    84 	
       
    85 RHTTPTransaction CTestCase24::GetTransactionL(TInt aIndex, RHTTPSession aSession, MHTTPTransactionCallback& aClient)
       
    86 	{
       
    87 	__ASSERT_ALWAYS(aIndex<TotalTransactionCount(), User::Invariant());
       
    88 	
       
    89 	RStringF method = aSession.StringPool().StringF(HTTP::EGET,RHTTPSession::GetTable());
       
    90 	_LIT8(KTxtUri, "http://127.0.0.1");
       
    91 	TUriParser8 uri; 
       
    92 	uri.Parse(KTxtUri());
       
    93 
       
    94 	if( aIndex==2 )
       
    95 		{
       
    96 		RHTTPTransaction trans = aSession.OpenTransactionL(uri, aClient, method);
       
    97 		AddConnectionCloseHeaderL(trans);
       
    98 		return trans;
       
    99 		}
       
   100 
       
   101 	return aSession.OpenTransactionL(uri, aClient, method);
       
   102 	}
       
   103 
       
   104 const TDesC8& CTestCase24::GetRawRequest(TInt aConnectionIndex, TInt aTransIndex)
       
   105 	{
       
   106 	__ASSERT_ALWAYS(aTransIndex<TransactionCount(aConnectionIndex), User::Invariant());
       
   107 	
       
   108 	if( aConnectionIndex==0 && aTransIndex==2 )
       
   109 		return KTxtRawRequestWithClose();
       
   110 
       
   111 	return KTxtRawRequest();
       
   112 	}
       
   113 	
       
   114 const TDesC8& CTestCase24::GetRawResponse(TInt aConnectionIndex, TInt aTransIndex)
       
   115 	{
       
   116 	__ASSERT_ALWAYS(aTransIndex<TransactionCount(aConnectionIndex), User::Invariant());
       
   117 	
       
   118 	return KTxtRawResponse();
       
   119 	}
       
   120 	
       
   121 void CTestCase24::AddConnectionCloseHeaderL(RHTTPTransaction aTransaction)
       
   122 	{
       
   123 	RStringF name = aTransaction.Session().StringPool().StringF(HTTP::EConnection, RHTTPSession::GetTable());
       
   124 	THTTPHdrVal value = aTransaction.Session().StringPool().StringF(HTTP::EClose, RHTTPSession::GetTable());
       
   125 
       
   126 	aTransaction.Request().GetHeaderCollection().SetFieldL(name, value);
       
   127 	}
       
   128 
       
   129 TBool CTestCase24::SetTransportHandlerPriority() const	
       
   130 	{
       
   131 	return ETrue;
       
   132 	}