applayerprotocols/httpservice/src/chttpservice.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Wed, 13 Oct 2010 15:09:28 +0300
branchRCL_3
changeset 53 c59bddbfd7b9
parent 40 a0da872af3fa
permissions -rw-r--r--
Revision: 201038 Kit: 201041
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37
5f1cd966e0d9 Revision: 201029
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 9
diff changeset
     1
// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
0
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
// All rights reserved.
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
// This component and the accompanying materials are made available
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
// under the terms of "Eclipse Public License v1.0"
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
// which accompanies this distribution, and is available
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
//
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
// Initial Contributors:
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
// Nokia Corporation - initial contribution.
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
//
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
// Contributors:
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
//
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
// Description:
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
//
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
#include "chttpservice.h"
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
#include "httpclientutils.h"
7
337070b4fa18 Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    18
#include "chttpclientauthentication.h" 
337070b4fa18 Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    19
#include "mhttpserviceauthentication.h" 
9
2611c08ee28e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 7
diff changeset
    20
#include "chttpnetworkconnectioninfo.h"
0
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
const TInt KMaxNoOfConnections = 6;
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
const TInt KMaxTransToPipeline = 5;
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
/**
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
 * The default 2-phase constructor to create a CHttpService instance
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
 * 
40
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
    27
 * @publishedAll
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
    28
 * @prototype 
0
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    29
 */
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    30
EXPORT_C CHttpService* CHttpService::NewL()
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
	{
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    32
    CHttpService* self = new(ELeave) CHttpService;
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    33
	CleanupStack::PushL(self);
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
	self->ConstructL();
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
	CleanupStack::Pop(); // self
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
	return self;	
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
	}
53
c59bddbfd7b9 Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 40
diff changeset
    38
	
0
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
/**
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
 * Destructor
40
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
    41
 * @publishedAll
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
    42
 * @prototype 
0
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    43
 */	
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    44
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    45
EXPORT_C CHttpService::~CHttpService()
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    46
	{
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    47
	if(iHttpServiceStruct)
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    48
	    {
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    49
	iHttpServiceStruct->iHttpSession.Close();
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    50
	    }
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    51
	delete iHttpServiceStruct;
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    52
	}
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    53
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    54
/**
7
337070b4fa18 Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    55
 * Destructor of the inner class CHttpServiceStruct
53
c59bddbfd7b9 Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 40
diff changeset
    56
 *
40
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
    57
 * @publishedAll
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
    58
 * @prototype 
7
337070b4fa18 Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    59
 */ 
337070b4fa18 Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    60
CHttpService::CHttpServiceStruct::~CHttpServiceStruct()
337070b4fa18 Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    61
    {
337070b4fa18 Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    62
    delete iHttpClientAuthentication;
337070b4fa18 Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    63
    }
337070b4fa18 Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    64
337070b4fa18 Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
    65
/**
0
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    66
 * Retrieves the equivalent string for a give string ID from the 
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
 * HTTP string pool
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    68
 * 
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    69
 * @param @aStringId String ID
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    70
 * @param aPtr  String
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    71
 * 
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    72
 * @return KErrNotFound if the string ID is not found in the HTTP string pool
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
 *          otherwise KErrNone for success
40
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
    74
 *
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
    75
 * @publishedAll
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
    76
 * @prototype 
0
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    77
 */
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    78
EXPORT_C TInt CHttpService::String(TInt aStringId, TPtrC8& aPtr)
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    79
    {
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    80
    RStringF str = iHttpServiceStruct->iHttpSession.StringPool().StringF(aStringId, RHTTPSession::GetTable());
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    81
    aPtr.Set(str.DesC());
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    82
    return KErrNone;
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    83
    }
53
c59bddbfd7b9 Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 40
diff changeset
    84
    
0
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    85
/**
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    86
 * Set the proxy that applies to all HTTP client transactions that "this"
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    87
 * CHttpService instance creates
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    88
 * 
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    89
 * @param aProxyAddress Proxy address. [for ex;  http://myproxy.org:8081]
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    90
 * @return KErrNoMemory if the proxy information cannot be set other KErrNone for success.
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    91
 * 
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    92
 */
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    93
EXPORT_C TInt CHttpService::SetProxy(const TDesC8& aProxyAddress)
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    94
	{
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    95
	RHTTPSession sess = iHttpServiceStruct->iHttpSession;
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    96
	RStringPool sp = sess.StringPool();
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    97
	RHTTPConnectionInfo connInfo = sess.ConnectionInfo();
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    98
	RStringF property  = sp.StringF(HTTP::EProxyUsage, RHTTPSession::GetTable());
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    99
	RStringF useProxy = sp.StringF(HTTP::EUseProxy, RHTTPSession::GetTable());
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   100
	TInt err = connInfo.SetProperty(property, useProxy);
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   101
	if(err == KErrNone)
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   102
		{
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   103
		RStringF str;
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   104
		err = HttpClientUtils::OpenStringF(aProxyAddress, sp, str);
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   105
		if(err == KErrNone)
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   106
		    {
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   107
		    err = connInfo.SetProperty(sp.StringF(HTTP::EProxyAddress,RHTTPSession::GetTable()), str);
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   108
		    str.Close();
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   109
		    }
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   110
		}		
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   111
	return err;	
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   112
	}
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   113
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   114
/**
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   115
 * Returns the proxy address that is set
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   116
 * 
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   117
 * @return Proxy address otherwise KNullDesC8 if the proxy information
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   118
 *         is not set.
53
c59bddbfd7b9 Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 40
diff changeset
   119
 *
40
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   120
 * @publishedAll
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   121
 * @prototype 
0
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   122
 */
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   123
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   124
EXPORT_C const TDesC8& CHttpService::ProxyAddress() const
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   125
	{
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   126
	RHTTPSession sess = iHttpServiceStruct->iHttpSession;
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   127
	RStringPool sp = sess.StringPool();
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   128
	RHTTPConnectionInfo connInfo = sess.ConnectionInfo();
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   129
	THTTPHdrVal useProxy;
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   130
	if(connInfo.Property(sp.StringF(HTTP::EProxyUsage, RHTTPSession::GetTable()), useProxy))
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   131
		{
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   132
		THTTPHdrVal proxyAddress;
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   133
		if(connInfo.Property(sp.StringF(HTTP::EProxyAddress, RHTTPSession::GetTable()), proxyAddress))
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   134
			{
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   135
			return proxyAddress.StrF().DesC();			
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   136
			}
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   137
		}
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   138
	return KNullDesC8();
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   139
	}
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   140
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   141
/**
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   142
 * Set the maxuimum number of TCP connections[socket] CHttpService instance that can activated 
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   143
 * at any time. The default no. of connections that the CHttpService instance uses is 6.
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   144
 * 
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   145
 * @param aValue aValue No. of connections
53
c59bddbfd7b9 Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 40
diff changeset
   146
 *
40
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   147
 * @publishedAll
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   148
 * @prototype 
0
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   149
 */
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   150
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   151
EXPORT_C void CHttpService::SetMaxConnections(TInt aValue)
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   152
	{
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   153
	RHTTPSession sess = iHttpServiceStruct->iHttpSession;
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   154
	RStringPool sp = sess.StringPool();
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   155
	RHTTPConnectionInfo connInfo = sess.ConnectionInfo();
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   156
	
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   157
	connInfo.SetProperty(sp.StringF(HTTP::EMaxNumTransportHandlers, RHTTPSession::GetTable()), THTTPHdrVal(aValue));		
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   158
	}
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   159
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   160
/**
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   161
 * Returns the maximum no. of TCP connections that is set.
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   162
 * 
40
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   163
 * @publishedAll
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   164
 * @prototype 
0
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   165
 */
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   166
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   167
EXPORT_C TInt CHttpService::MaxConnections() const
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   168
	{
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   169
	RHTTPSession sess = iHttpServiceStruct->iHttpSession;
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   170
	RStringPool sp = sess.StringPool();
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   171
	RHTTPConnectionInfo connInfo = sess.ConnectionInfo();
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   172
	THTTPHdrVal val;
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   173
	if(connInfo.Property(sp.StringF(HTTP::EMaxNumTransportHandlers, RHTTPSession::GetTable()), val))
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   174
		{
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   175
		if(val.Type() == THTTPHdrVal::KTIntVal)
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   176
			return val.Int();
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   177
		}
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   178
	return 0;
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   179
	}
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   180
	
40
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   181
/**
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   182
 * Sets the maximum number of transactions to be pipelined.
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   183
 * @param aValue - number of transactions
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   184
 *
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   185
 * @publishedAll
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   186
 * @prototype 
53
c59bddbfd7b9 Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 40
diff changeset
   187
 */	
0
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   188
EXPORT_C void CHttpService::SetMaxTransactionsToPipeline(TInt aValue)
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   189
	{
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   190
	RHTTPSession sess = iHttpServiceStruct->iHttpSession;
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   191
	RStringPool sp = sess.StringPool();
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   192
	RHTTPConnectionInfo connInfo = sess.ConnectionInfo();
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   193
	
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   194
	connInfo.SetProperty(sp.StringF(HTTP::EMaxNumTransactionsToPipeline, RHTTPSession::GetTable()), THTTPHdrVal(aValue));				
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   195
	}
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   196
	
40
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   197
/**
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   198
 * Returns the maximum number of transactions to be pipelined.
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   199
 * 
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   200
 * @publishedAll
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   201
 * @prototype 
53
c59bddbfd7b9 Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 40
diff changeset
   202
 */		
0
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   203
EXPORT_C TInt CHttpService::MaxTransactionsToPipeline() const
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   204
	{
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   205
	RHTTPSession sess = iHttpServiceStruct->iHttpSession;
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   206
	RStringPool sp = sess.StringPool();
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   207
	RHTTPConnectionInfo connInfo = sess.ConnectionInfo();
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   208
	THTTPHdrVal val;
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   209
	if(connInfo.Property(sp.StringF(HTTP::EMaxNumTransactionsToPipeline, RHTTPSession::GetTable()), val))
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   210
		{
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   211
		if(val.Type() == THTTPHdrVal::KTIntVal)
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   212
			return val.Int();
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   213
		}
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   214
	return 0;		
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   215
	}
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   216
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   217
/**
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   218
 * This method facilitates to set the header once in the CHttpService instance that is applicable
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   219
 * for all HTTP client transactions. [For ex; User-Agent header] 
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   220
 * 
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   221
 * @param aStringId - Pre-defined String ID in the HTTP string pool
53
c59bddbfd7b9 Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 40
diff changeset
   222
 * @param aHeaderValue - Value for the header 
c59bddbfd7b9 Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 40
diff changeset
   223
 *
40
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   224
 * @publishedAll
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   225
 * @prototype 
0
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   226
 */
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   227
EXPORT_C TInt CHttpService::AddRequestHeader(TInt aStringId, const THttpHeaderValueVariant& aHeaderValue)
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   228
	{
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   229
	RHTTPHeaders sessHeaders = iHttpServiceStruct->iSessionHeaders;
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   230
    RStringPool sp = iHttpServiceStruct->iHttpSession.StringPool();
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   231
    THTTPHdrVal val = HttpClientUtils::CopyHttpHdrVal(aHeaderValue, sp);
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   232
    TInt err = sessHeaders.SetField(sp.StringF(aStringId, RHTTPSession::GetTable()), val);
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   233
    HttpClientUtils::CloseString(val);
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   234
    return err;
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   235
	}
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   236
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   237
/**
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   238
 * This method facilitates to set the custom HTTP header once in the CHttpService instance that is 
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   239
 * applicable for all HTTP client transactions. [For ex; User-Agent header] 
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   240
 * 
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   241
 * @param aHeaderName - Custom header name
53
c59bddbfd7b9 Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 40
diff changeset
   242
 * @param aHeaderValue - Value for the header 
c59bddbfd7b9 Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 40
diff changeset
   243
 *
40
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   244
 * @publishedAll
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   245
 * @prototype 
0
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   246
 */
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   247
EXPORT_C TInt CHttpService::AddCustomRequestHeader(const TDesC8& aHeaderName, const TDesC8& aHeaderValue)
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   248
	{
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   249
	_LIT8(KFieldSeparator, "\n");
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   250
	RStringPool sp = iHttpServiceStruct->iHttpSession.StringPool();
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   251
	RStringF str;
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   252
	if(HttpClientUtils::OpenStringF(aHeaderName, sp, str) != KErrNone)
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   253
        {
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   254
        return KErrNoMemory;
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   255
        }
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   256
	TInt err = iHttpServiceStruct->iSessionHeaders.SetRawField(str, aHeaderValue, KFieldSeparator);
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   257
	str.Close();
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   258
	return err;
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   259
	}
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   260
40
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   261
/**
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   262
 * This method facilitates to set to construct the authentication credentials to be passed by the application
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   263
 * The derived class from MHTTPServiceAuthentication  will be called from the framework, if authentication is required.
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   264
 * @param aCallback - Derived class from MHTTPServiceAuthentication
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   265
 *
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   266
 * @publishedAll
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   267
 * @prototype 
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   268
 */
7
337070b4fa18 Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   269
EXPORT_C TInt CHttpService::SetAuthentication(MHTTPServiceAuthentication* aCallback)
337070b4fa18 Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   270
    {
337070b4fa18 Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   271
    TInt error = KErrGeneral;
337070b4fa18 Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   272
    iHttpServiceStruct->iHttpClientAuthentication = CHttpClientAuthentication::New(iHttpServiceStruct->iHttpSession, aCallback);
337070b4fa18 Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   273
    if(iHttpServiceStruct->iHttpClientAuthentication)
337070b4fa18 Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   274
        error = KErrNone;
337070b4fa18 Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   275
    return error;
337070b4fa18 Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   276
    }
337070b4fa18 Revision: 201004
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   277
0
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   278
/**
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   279
 * Constructor
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   280
 */
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   281
CHttpService::CHttpService()
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   282
: iHttpServiceStruct(NULL)
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   283
	{
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   284
	}
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   285
	
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   286
void CHttpService::ConstructL()
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   287
	{
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   288
    iHttpServiceStruct = new(ELeave) CHttpServiceStruct();
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   289
    iHttpServiceStruct->iHttpSession.OpenL();
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   290
    iHttpServiceStruct->iSessionHeaders = iHttpServiceStruct->iHttpSession.RequestSessionHeadersL();
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   291
    SetMaxConnections(KMaxNoOfConnections);
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   292
    SetMaxTransactionsToPipeline(KMaxTransToPipeline);    
b16258d2340f Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   293
	}
53
c59bddbfd7b9 Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 40
diff changeset
   294
40
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   295
/**
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   296
 * returns the CHttpNetworkConnection instance created by the framework.
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   297
 * The class can be used to set the connection properties.
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   298
 *
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   299
 * @publishedAll
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   300
 * @prototype 
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   301
 */
9
2611c08ee28e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 7
diff changeset
   302
EXPORT_C CHttpNetworkConnection* CHttpService::HttpNetworkConnection()
2611c08ee28e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 7
diff changeset
   303
    {
2611c08ee28e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 7
diff changeset
   304
    CHttpNetworkConnection *httpNetworkConn = CHttpNetworkConnection::New();
2611c08ee28e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 7
diff changeset
   305
    httpNetworkConn->SetHttpService(this);
2611c08ee28e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 7
diff changeset
   306
    return httpNetworkConn;
2611c08ee28e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 7
diff changeset
   307
    }
40
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   308
53
c59bddbfd7b9 Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 40
diff changeset
   309
40
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   310
void CHttpService::RemoveUnwantedFilters()
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   311
    {
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   312
    THTTPFilterRegistration filterInfo;
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   313
    RStringPool stringPool = iHttpServiceStruct->iHttpSession.StringPool();
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   314
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   315
    RHTTPFilterCollection filterArray = iHttpServiceStruct->iHttpSession.FilterCollection();
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   316
    THTTPFilterIterator iter = filterArray.Query();
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   317
    const TStringTable& st = RHTTPSession::GetTable();
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   318
  
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   319
    iter.First();
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   320
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   321
    while (!iter.AtEnd())
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   322
        {
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   323
        // Get next filter registration info
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   324
        filterInfo = iter();
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   325
        RStringF filterName = stringPool.StringF(filterInfo.iName);
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   326
        switch(filterName.Index(st))
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   327
            {
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   328
            //dont remove these filters
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   329
            case HTTP::EClient:
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   330
            case HTTP::EProtocolHandler:
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   331
            case HTTP::EValidation:
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   332
            case HTTP::ERedirect:
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   333
            case HTTP::EHttpConnectFilter:
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   334
                break;
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   335
            //anything other than above, remove.    
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   336
            default:
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   337
                filterArray.RemoveFilter(filterName);
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   338
             }
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   339
        ++iter;
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   340
        }
a0da872af3fa Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 39
diff changeset
   341
    }