common/tools/ats/smoketest/http/src/testhttpbuffersizestep.cpp
author victorp@symbian.org
Wed, 03 Feb 2010 16:06:24 +0000
changeset 872 17498133d9ad
parent 836 675529c38614
permissions -rw-r--r--
adding EPL headers to smoke test
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
836
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     1
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     2
// All rights reserved.
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     3
// This component and the accompanying materials are made available
872
17498133d9ad adding EPL headers to smoke test
victorp@symbian.org
parents: 836
diff changeset
     4
// under the terms of the License "Eclipse Public License v1.0"
836
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     5
// which accompanies this distribution, and is available
872
17498133d9ad adding EPL headers to smoke test
victorp@symbian.org
parents: 836
diff changeset
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
836
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     7
//
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     8
// Initial Contributors:
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
     9
// Nokia Corporation - initial contribution.
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    10
//
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    11
// Contributors:
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    12
//
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    13
// Description:
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    14
// Contains implementation of CTestHttpBufferSizeStep class
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    15
// @internalAll
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    16
// 
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    17
//
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    18
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    19
// System Include
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    20
// for StartC32()
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    21
#include <c32comm.h>
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    22
#include <e32base.h>
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    23
#include <http.h>
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    24
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    25
// User Include
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    26
#include "testhttpbuffersizestep.h"
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    27
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    28
// File system root
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    29
_LIT(KFileSystemRoot,"C:\\");
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    30
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    31
// Standard headers used by default
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    32
_LIT8(KUserAgent, "TestHttpBufferSize");
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    33
_LIT8(KAccept, "*/*");
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    34
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    35
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    36
/**
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    37
Constructor: Sets the test step name.
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    38
@internalTechnology
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    39
@test
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    40
*/
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    41
CTestHttpBufferSizeStep::CTestHttpBufferSizeStep()
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    42
	{
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    43
	//Call base class method to set human readable name for test step
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    44
	SetTestStepName(KTestHttpBufferSizeStep); 
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    45
	//Set the iChunkSize to the default buffer size of 6144 Bytes
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    46
	iChunkSize = 1024;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    47
	}
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    48
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    49
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    50
/**
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    51
Destructor: Closes the iFileServ.
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    52
@internalTechnology
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    53
@test
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    54
*/
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    55
CTestHttpBufferSizeStep::~CTestHttpBufferSizeStep()
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    56
	{
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    57
	}
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    58
	
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    59
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    60
/**
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    61
Sets the proxy and HttpDataOptimiser implemetation to session
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    62
based on the patameter values in ini file and calls InvokeHttpMethodL()
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    63
@internalTechnology
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    64
@test
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    65
@param		None
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    66
@return		None
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    67
*/
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    68
void CTestHttpBufferSizeStep::StartClientL()
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    69
	{
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    70
	TPtrC uri;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    71
	
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    72
    if (!GetStringFromConfig(ConfigSection(), KIniUri, uri))
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    73
		{
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    74
		ERR_PRINTF2(_L("Problem in reading values from ini.			\
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    75
						\nExpected fields are: \n%S\n"
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    76
					  ),&KIniUri);
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    77
		SetTestStepResult(EFail);
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    78
		return;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    79
		}
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    80
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    81
	THTTPHdrVal hdrVal ( 1024 );
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    82
	RHTTPConnectionInfo httpConnInfo = iSess.ConnectionInfo();
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    83
	httpConnInfo.SetPropertyL ( iSess.StringPool().StringF(HTTP::ERecvBufferSize,RHTTPSession::GetTable()), hdrVal );
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    84
	INFO_PRINTF1(_L("Receive buffer size has been set to 1024 bytes\n"));
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    85
	
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    86
	RStringPool strP = iSess.StringPool();
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    87
	RStringF method;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    88
	
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    89
	// method
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    90
	method = strP.StringF(HTTP::EGET,RHTTPSession::GetTable());		
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    91
	TBuf8<256> url8;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    92
	url8.Copy(uri);
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    93
	TRAPD(err,InvokeHttpMethodL(url8, method));
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    94
	if (err != KErrNone)
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    95
		{
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    96
		ERR_PRINTF2(_L("Teststep Failed: Leave occured in CTestHttpBufferSizeStep::InvokeHttpMethodL: %D\n"
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    97
					  ),err
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    98
				   );
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
    99
		SetTestStepResult(EFail);
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   100
		}
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   101
	method.Close(); 
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   102
	ValidateTest();
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   103
	}
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   104
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   105
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   106
/**
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   107
Invoke the http method
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   108
This actually creates the transaction, sets the headers and HttpDataOptimiser implemetation to transaction
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   109
and then starts the transaction 
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   110
@internalTechnology
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   111
@test
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   112
@param		aUri 		Requested uri
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   113
@param		aMethod 	Requested method
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   114
@return		None		
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   115
*/
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   116
void CTestHttpBufferSizeStep::InvokeHttpMethodL(const TDesC8& aUri, RStringF aMethod)
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   117
	{
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   118
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   119
	TUriParser8 uri; 
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   120
	uri.Parse( aUri );
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   121
	
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   122
	// Opening a transaction	
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   123
	iTrans = iSess.OpenTransactionL(uri, *this, aMethod);
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   124
	RHTTPHeaders hdr = iTrans.Request().GetHeaderCollection();
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   125
	// Add headers appropriate to all methods
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   126
	SetHeaderL(hdr, HTTP::EUserAgent, KUserAgent);
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   127
	SetHeaderL(hdr, HTTP::EAccept, KAccept);
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   128
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   129
	// submit the transaction
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   130
	iTrans.SubmitL();
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   131
	// Start the scheduler, once the transaction completes or is cancelled on an error the scheduler will be
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   132
	// stopped in the event handler
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   133
	CActiveScheduler::Start();
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   134
	}
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   135
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   136
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   137
/**
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   138
This is the implementation of interface method CTestHttpBufferSizeStep::MHFRunL
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   139
If there is a reponse body it will be copied to a file.
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   140
Just printing the fired events to the log file.
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   141
@internalTechnology 
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   142
@test
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   143
@param		aTransaction Transaction which is being processed currently
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   144
@param      THTTPEvent Event for which it is called
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   145
@return		None
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   146
*/	
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   147
void CTestHttpBufferSizeStep::MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent)
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   148
	{
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   149
	switch (aEvent.iStatus)
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   150
		{
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   151
		case THTTPEvent::EGotResponseHeaders:
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   152
			{
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   153
			// HTTP response headers have been received. We can determine now if there is
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   154
			// going to be a response body to save.
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   155
			RHTTPResponse resp = aTransaction.Response();
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   156
			TInt status = resp.StatusCode();
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   157
			RStringF statusStr = resp.StatusText();
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   158
			TBuf<32> statusStr16;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   159
			statusStr16.Copy(statusStr.DesC());
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   160
			INFO_PRINTF3(_L("Status: %D (%S)\n"),status, &statusStr16);
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   161
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   162
			if (resp.HasBody() && (status >= 200) && (status < 300) && (status != 204))
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   163
				{
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   164
				TInt dataSize = resp.Body()->OverallDataSize();
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   165
				if (dataSize >= 0)
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   166
					INFO_PRINTF2(_L("Response body size is %d\n"), dataSize);
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   167
				else
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   168
					INFO_PRINTF1(_L("Response body size is unknown\n"));
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   169
				}
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   170
			} break;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   171
		case THTTPEvent::EGotResponseBodyData:
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   172
			{
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   173
			// Get the body data supplier
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   174
			iRespBody = aTransaction.Response().Body();
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   175
			INFO_PRINTF1(_L("Receiving response body...\n"));
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   176
			
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   177
			TPtrC8 bodyData;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   178
			TBool lastChunk = iRespBody->GetNextDataPart(bodyData);
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   179
			if(bodyData.Size() > iChunkSize)
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   180
				{
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   181
				iChunkSize = bodyData.Size();
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   182
				}
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   183
			iRespBody->ReleaseData();
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   184
			} break;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   185
		case THTTPEvent::EResponseComplete:
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   186
			{
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   187
			// The transaction's response is complete
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   188
			INFO_PRINTF1(_L("\nTransaction Complete\n"));
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   189
			} break;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   190
		case THTTPEvent::ESucceeded:
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   191
			{
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   192
			INFO_PRINTF1(_L("Transaction Successful\n"));
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   193
			aTransaction.Close();
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   194
			CActiveScheduler::Stop();
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   195
			} break;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   196
		case THTTPEvent::EFailed:
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   197
			{
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   198
			INFO_PRINTF1(_L("Transaction Failed\n"));
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   199
			aTransaction.Close();
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   200
			CActiveScheduler::Stop();
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   201
			} break;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   202
		case THTTPEvent::ERedirectedPermanently:
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   203
			{
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   204
			INFO_PRINTF1(_L("Permanent Redirection\n"));
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   205
			} break;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   206
		case THTTPEvent::ERedirectedTemporarily:
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   207
			{
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   208
			INFO_PRINTF1(_L("Temporary Redirection\n"));
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   209
			} break;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   210
		case THTTPEvent::ERedirectRequiresConfirmation:
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   211
 			{
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   212
			// 301(Moved Permanently), 302(Found) or 307(Temporary Redirect) status is received 
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   213
			// from a transaction and hence ERedirectRequiresConfirmation is sent by filter
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   214
			// client has opted to close the transaction
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   215
			INFO_PRINTF1(_L("Redirect requires confirmation\n"));
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   216
 			aTransaction.Close();
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   217
 			CActiveScheduler::Stop();
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   218
 			} break;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   219
		default:
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   220
			{
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   221
			INFO_PRINTF2(_L("<unrecognised event: %D>\n"), aEvent.iStatus);
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   222
			// close off the transaction if it's an error
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   223
			if (aEvent.iStatus < 0)
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   224
				{
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   225
				aTransaction.Close();
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   226
				CActiveScheduler::Stop();
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   227
				}
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   228
			} break;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   229
		}
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   230
	}
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   231
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   232
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   233
/**
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   234
This is the implementation of interface method CTestHttpBufferSizeStep::MHFRunError
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   235
@internalTechnology 
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   236
@test
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   237
@param		aError  Error which has been raised.	
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   238
@param		aTransaction Transaction which is being processed currently
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   239
@param      THTTPEvent Event which it is being handled currently.
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   240
@return		None
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   241
*/
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   242
TInt CTestHttpBufferSizeStep::MHFRunError(TInt aError, RHTTPTransaction /*aTransaction*/, const THTTPEvent& /*aEvent*/)
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   243
	{
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   244
	INFO_PRINTF2(_L("MHFRunError fired with error code %D\n"), aError);
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   245
	return KErrNone;
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   246
	}
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   247
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   248
void CTestHttpBufferSizeStep::ValidateTest()
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   249
	{
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   250
	if(iChunkSize <= 1024)
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   251
		{
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   252
		ERR_PRINTF1(_L("Teststep Passed: Buffer Size Feature is working\n"));
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   253
		}
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   254
	else
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   255
		{
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   256
		ERR_PRINTF2(_L("Received a chunk of size: %D\n"), iChunkSize);
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   257
		ERR_PRINTF1(_L("Received a chunk of size greater than the specified size of 1024 Bytes.\n"));
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   258
		ERR_PRINTF1(_L("Teststep Failed: Buffer Size Feature is not working\n"));
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   259
		SetTestStepResult(EFail);
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   260
		}
675529c38614 Added smoke test for making a connection to a web server through ethernet
Maciej Seroka <maciejs@symbian.org>
parents:
diff changeset
   261
	}