Example #1
0
/**
    Setup dir structure for testing and verifying functional results
    @param	datastr			data structure to setup directory
    @param  iOperation   	Operation to be performed 
    @param  SrcDrive		Source drive
    @param	Targetdrive		Target drive input
    @panic					if data structure definition is incorrect
*/
void SetupDirFiles(const TDesC& aPath, const TDirSetupFiles& aDirFiles)
	{
	TFileName path = aPath;
	if (path.Length() == 0)
		{
		test.Printf(_L("ERROR<SetupDirFiles()>: Zero length src path!\n"));
		test(EFalse);
		}
	
	MakeDir(path);
	
	RArray<TInt> addBlockDataArray;
	RArray<TInt> deductBlockDataArray;
	
	ParsingDirDataBlock(aDirFiles.iAddingBlock, addBlockDataArray);
	ParsingDirDataBlock(aDirFiles.iDeductBlock, deductBlockDataArray);
	
	if (addBlockDataArray.Count() == 0)
	// empty dir setup
		{
		return;
		}
	for (TInt i = 0; i < deductBlockDataArray.Count(); ++i)
		{
		TInt idxToDelete = addBlockDataArray.FindInOrder(deductBlockDataArray[i]);
		if (idxToDelete >= 0)
			{
			addBlockDataArray.Remove(idxToDelete);
			}
		else if (idxToDelete == KErrNotFound)
			{
			continue;
			}
		else
			{
			test.Printf(_L("ERROR<<SetupDir>>: wrong dir data setup! err=%d\n"), idxToDelete);
			test(EFalse);
			}
		}
	if (addBlockDataArray.Count() > 0)
		{
		for (TInt i = 0; i < addBlockDataArray.Count(); ++i)
			{
			TInt idx = addBlockDataArray[i];
			path = aPath;
			path += gDirPatterns[idx];
			if (path[path.Length() - 1] == '\\')
				{
				MakeDir(path);
				}
			else
				{
				MakeFile(path, _L8("blahblah"));
				}
			}
		}
	
	addBlockDataArray.Reset();
	deductBlockDataArray.Reset();
	}
void CHttpController::SendRequestL( TInt aMethodIndex, const TDesC8& aUri, CHttpHeaders* aHeaders )
	{
	if ( !iObserver )
		{
		User::Leave( KErrHttpInvalidObserver );
		}
	RStringF method = iSession.StringPool().StringF( aMethodIndex, RHTTPSession::GetTable() );

	TUriParser8 uri;
	uri.Parse( aUri );
	iTransaction = iSession.OpenTransactionL( uri, *this, method );
	RHTTPHeaders hdr = iTransaction.Request().GetHeaderCollection();

	RArray< TInt > addedElements;
	CleanupClosePushL( addedElements );

	SetHeaderL( HTTP::EUserAgent, hdr, KUserAgent, addedElements );
	SetHeaderL( HTTP::EConnection, hdr, KClose, addedElements );
	SetHeaderL( HTTP::EAccept, hdr, KAccept, addedElements );
	SetHeaderL( HTTP::EHost, hdr, uri.Extract( EUriHost ), addedElements );

	TInt count( iPersistentHeaders->Count() );
	for ( TInt i( 0 ); i < count; ++i )
		{
		if ( addedElements.FindInOrder( i ) >= 0 )
			{
			continue;
			}
		SetHeaderL( hdr, iPersistentHeaders->Key( i ), iPersistentHeaders->Value( i ) );
		}

	CleanupStack::PopAndDestroy( &addedElements );
	if ( aHeaders )
		{
		TInt count( aHeaders->Count() );
		for ( TInt i( 0 ); i < count; ++i )
			{
			SetHeaderL( hdr, aHeaders->Key( i ), aHeaders->Value( i ) );
			}
		}

	if ( aMethodIndex == HTTP::EPOST )
		{
		const TInt KMaxContentLenBufferLength = 100;
		TBuf8< KMaxContentLenBufferLength > contentLength;
		contentLength.Num( iOutputEncoder->OverallDataSize() );
		SetHeaderL( hdr, HTTP::EContentLength, contentLength );
		SetHeaderL( hdr, HTTP::EContentType, KUrlEncodedContentType );
		iTransaction.Request().SetBody( *iOutputEncoder );
		}
	iTransaction.SubmitL();
	StartTimeout();
	iState = EHttpActive;
	}