epoc32/include/mw/http/rhttpsession.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 epoc32/include/http/rhttpsession.h@2fe1408b6811
child 4 837f303aceeb
permissions -rw-r--r--
Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
williamr@2
     1
// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     2
// All rights reserved.
williamr@2
     3
// This component and the accompanying materials are made available
williamr@2
     4
// under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
williamr@2
     5
// which accompanies this distribution, and is available
williamr@2
     6
// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
williamr@2
     7
//
williamr@2
     8
// Initial Contributors:
williamr@2
     9
// Nokia Corporation - initial contribution.
williamr@2
    10
//
williamr@2
    11
// Contributors:
williamr@2
    12
//
williamr@2
    13
// Description:
williamr@2
    14
//
williamr@2
    15
williamr@2
    16
williamr@2
    17
williamr@2
    18
/**
williamr@2
    19
 @file RHTTPSession.h
williamr@2
    20
 @warning : This file contains Rose Model ID comments - please do not delete
williamr@2
    21
*/
williamr@2
    22
williamr@2
    23
#ifndef __RHTTPSESSION_H__
williamr@2
    24
#define __RHTTPSESSION_H__ 
williamr@2
    25
williamr@2
    26
// System includes
williamr@2
    27
#include <e32std.h>
williamr@2
    28
#include <uri8.h>
williamr@2
    29
#include <http/rhttpconnectioninfo.h>
williamr@2
    30
#include <http/rhttpfiltercollection.h>
williamr@2
    31
#include <http/rhttptransaction.h>
williamr@2
    32
#include <http/mhttpdataoptimiser.h>
williamr@2
    33
williamr@2
    34
// Forward declarations
williamr@2
    35
class MHTTPTransactionCallback;
williamr@2
    36
class CHTTPSession;
williamr@2
    37
class MHTTPSessionEventCallback;
williamr@2
    38
class MHTTPFilterCreationCallback;
williamr@2
    39
class TCertInfo;
williamr@2
    40
class CCertificate;
williamr@2
    41
williamr@2
    42
/**
williamr@2
    43
Constant to represent any HTTP Status code when registering filters.
williamr@2
    44
@publishedAll
williamr@2
    45
@released
williamr@2
    46
*/
williamr@2
    47
const TInt KAnyStatusCode = -1;
williamr@2
    48
williamr@2
    49
williamr@2
    50
//##ModelId=3C4C187B0280
williamr@2
    51
class RHTTPSession 
williamr@2
    52
/** 
williamr@2
    53
A session handle. A session is a set of HTTP transactions using
williamr@2
    54
the same connection settings (e.g. proxy) and the same set of filters.
williamr@2
    55
    Multi-homing support provided by HTTP framework enables clients to
williamr@2
    56
    specify Connection preferences through the session property 
williamr@2
    57
    EHttpSocketConnection.
williamr@2
    58
williamr@2
    59
Note that RHTTPSession (and consequently the whole of HTTP)
williamr@2
    60
depends on the active scheduler; a scheduler must be installed
williamr@2
    61
when the session is opened and it must be running if a transaction
williamr@2
    62
is actually to do anything.
williamr@2
    63
@publishedAll
williamr@2
    64
@released
williamr@2
    65
@see RHTTPTransaction
williamr@2
    66
*/
williamr@2
    67
	{
williamr@2
    68
 public:
williamr@2
    69
	/** Constructor.
williamr@2
    70
		@post The session is closed. (It must be opened with OpenL)
williamr@2
    71
		@see OpenL */
williamr@2
    72
	//##ModelId=3C4C187B02EF
williamr@2
    73
	inline RHTTPSession();
williamr@2
    74
williamr@2
    75
	/** Sets the session event callback.
williamr@2
    76
		Until it is set all incoming session events are consumed
williamr@2
    77
	*/
williamr@2
    78
	//##ModelId=3C4C187B02EA
williamr@2
    79
	IMPORT_C void SetSessionEventCallback(MHTTPSessionEventCallback* aSessionEventCallback);
williamr@2
    80
williamr@2
    81
	/** Send an session event
williamr@2
    82
		@param aEvent. The session event to sent.
williamr@2
    83
	*/
williamr@2
    84
	//##ModelId=3C4C187B02E6
williamr@2
    85
	IMPORT_C void SendSessionEventL(THTTPSessionEvent aStatus, THTTPSessionEvent::TDirection aDirection, 
williamr@2
    86
							 THTTPFilterHandle aStart = THTTPFilterHandle::EClient);
williamr@2
    87
williamr@2
    88
	/** Fail the session event
williamr@2
    89
	*/
williamr@2
    90
	IMPORT_C void FailSessionEvent(THTTPFilterHandle aStart = THTTPFilterHandle::EClient);
williamr@2
    91
williamr@2
    92
	//##ModelId=3A49F701013F
williamr@2
    93
	/** Opens the session using the default protocol HTTP/TCP. 
williamr@2
    94
		This function leaves with an apropriate code if the open failed.
williamr@2
    95
		@pre The session is closed. An active scheduler is installed.
williamr@2
    96
		@post The session is open.
williamr@2
    97
	*/
williamr@2
    98
	//##ModelId=3C4C187B02DA
williamr@2
    99
 	IMPORT_C void OpenL();
williamr@2
   100
williamr@2
   101
	/** Opens the session using the protocol indicated by the parameter passed in.
williamr@2
   102
		This function leaves with an apropriate code if the open failed.
williamr@2
   103
		@param aProtocol The protocol required
williamr@2
   104
		@pre The session is closed. An active scheduler is installed.
williamr@2
   105
		@post The session is open.
williamr@2
   106
	*/
williamr@2
   107
	//##ModelId=3C4C187B02DB
williamr@2
   108
	IMPORT_C void OpenL(const TDesC8& aProtocol);
williamr@2
   109
williamr@2
   110
	/** Opens the session using the protocol indicated by the parameter passed in.
williamr@2
   111
		This method should be used if configuring the installed filters is required.
williamr@2
   112
		Once construction if the session is complete the callback method passed in is
williamr@2
   113
		called passing in a TFilterConfigurationIterator to allow the filters that
williamr@2
   114
		are installed to be configured.
williamr@2
   115
		This function leaves with an apropriate code if the open failed.
williamr@2
   116
		@param aProtocol The protocol required
williamr@2
   117
		@param aSessionCallback The pointer to the object providing the call back method
williamr@2
   118
		@pre The session is closed. An active scheduler is installed.
williamr@2
   119
		@post The session is open.
williamr@2
   120
	*/
williamr@2
   121
	//##ModelId=3C4C187B02DD
williamr@2
   122
	IMPORT_C void OpenL(const TDesC8& aProtocol, MHTTPFilterCreationCallback* aSessionCallback);
williamr@2
   123
williamr@2
   124
	/**	This is a static methods that lists all the available protocols by adding the 
williamr@2
   125
		prorocol descriptors to the descriptor array passed in. Any existing data in the
williamr@2
   126
		descriptor array passed in is deleted.
williamr@2
   127
		This function leaves if the descriptor array can not be updated with the appropriate
williamr@2
   128
		array code.
williamr@2
   129
		@param aProtocolArray A pointer array to heap based descriptors. The data in this
williamr@2
   130
		array will be deleted and filled with descriptors containing the available protocols
williamr@2
   131
		@see OpenL
williamr@2
   132
	*/
williamr@2
   133
	//##ModelId=3C4C187B02D4
williamr@2
   134
	IMPORT_C static void ListAvailableProtocolsL(RPointerArray<HBufC8>& aProtocolArray);
williamr@2
   135
williamr@2
   136
	/** Creates a transaction. 
williamr@2
   137
		@pre The session is open
williamr@2
   138
		@param aURI The URI that the request will be sent to.
williamr@2
   139
		@param aCallback A callback for all status events relating to
williamr@2
   140
		this transaction.
williamr@2
   141
		@param aMethod The HTTP method to use (default: GET)
williamr@2
   142
		@leave KErrNoMemory There was not enough memory.
williamr@2
   143
	*/
williamr@2
   144
	//##ModelId=3C4C187B02D0
williamr@2
   145
	IMPORT_C RHTTPTransaction OpenTransactionL(const TUriC8& aURI, 
williamr@2
   146
									  MHTTPTransactionCallback& aCallback, 
williamr@2
   147
									  RStringF aMethod = RStringF());
williamr@2
   148
williamr@2
   149
	/** Closes the session. All transactions will be stopped and closed 
williamr@2
   150
		@post The session and all open transactions in it are closed.
williamr@2
   151
	 */
williamr@2
   152
	//##ModelId=3C4C187B02C8
williamr@2
   153
	IMPORT_C void Close();
williamr@2
   154
williamr@2
   155
williamr@2
   156
	//##ModelId=3C4C187B02C7
williamr@2
   157
	IMPORT_C  static const TStringTable& GetTable();
williamr@2
   158
williamr@2
   159
	/** Accessor for the HTTP string pool. 
williamr@2
   160
		@return A handle for the string pool used in HTTP.
williamr@2
   161
	 */
williamr@2
   162
	//##ModelId=3C4C187B02C6
williamr@2
   163
	IMPORT_C RStringPool StringPool() const;
williamr@2
   164
williamr@2
   165
	/** Accessor for the connection info for this session, and which
williamr@2
   166
		is used for all transactions in the session. Note that by and
williamr@2
   167
		large, the connection info should be set up before the first
williamr@2
   168
		transaction is created.  @return A handle to the connection
williamr@2
   169
		inf.  */
williamr@2
   170
	//##ModelId=3C4C187B02BE
williamr@2
   171
	IMPORT_C RHTTPConnectionInfo ConnectionInfo() const;
williamr@2
   172
williamr@2
   173
	/** Accessor for the filter collection. Note that the filter
williamr@2
   174
        collection can't be edited after the first transaction has
williamr@2
   175
        been created. */
williamr@2
   176
	//##ModelId=3C4C187B02BD
williamr@2
   177
	inline RHTTPFilterCollection FilterCollection() const;
williamr@2
   178
williamr@2
   179
williamr@2
   180
	/** Accessor for the session headers. These are headers that will get added to each request
williamr@2
   181
		They only become part of the transaction headers when a transaction is submitted and they will not 
williamr@2
   182
		replace headers that already exist in the transaction request 
williamr@2
   183
	*/
williamr@2
   184
	//##ModelId=3C4C187B02BC
williamr@2
   185
	IMPORT_C RHTTPHeaders RequestSessionHeadersL();
williamr@2
   186
williamr@2
   187
williamr@2
   188
	/** Accessor for the response session headers. These are headers that will get added to each response if the 
williamr@2
   189
	corresponding header doesn't already exist
williamr@2
   190
	*/
williamr@2
   191
	//##ModelId=3C4C187B02B6
williamr@2
   192
	IMPORT_C RHTTPHeaders ResponseSessionHeadersL();
williamr@2
   193
williamr@2
   194
	/** Equality operator.
williamr@2
   195
		@param aTrans The session to compare this one to.
williamr@2
   196
	*/
williamr@2
   197
	//##ModelId=3C4C187B02B4
williamr@2
   198
	TBool operator==(RHTTPSession aTrans) const;
williamr@2
   199
	/** Inequality operator
williamr@2
   200
		@param aTrans The session to compare this one to.
williamr@2
   201
	*/
williamr@2
   202
williamr@2
   203
	//##ModelId=3C4C187B02B2
williamr@2
   204
	TBool operator!=(RHTTPSession aTrans) const;
williamr@2
   205
williamr@2
   206
	/** Obtain the server certificate information for this session.  This function
williamr@2
   207
		should only be used for WSP, for text-mode use RHttpTransaction::ServerCert.
williamr@2
   208
		@see RHttpTransaction::ServerCert
williamr@2
   209
		@param	aServerCert A client supplied object into which the certificate
williamr@2
   210
		information will be placed.
williamr@2
   211
		@return KErrNone if certificate has been completed, KErrNotSupported if
williamr@2
   212
		this function is called for text-mode.
williamr@2
   213
		@deprecated v9.2 onwards - maintained for compatibility with v9.1 and before
williamr@2
   214
					TCertInfo has been deprecated since v9.2. CCertificate may be used as an alternative.
williamr@2
   215
	*/
williamr@2
   216
	//##ModelId=3C4C187B02AA
williamr@2
   217
	IMPORT_C TInt ServerCert(TCertInfo& aServerCert);
williamr@2
   218
williamr@2
   219
williamr@2
   220
	/** Obtain the server certificate information for this session.  This function
williamr@2
   221
		should only be used for WSP. HTTP should use RHttpTransaction::ServerCert.
williamr@2
   222
		@see RHttpSession::ServerCert
williamr@2
   223
		@internalAll
williamr@2
   224
		@prototype
williamr@2
   225
		@return	a CCertificate pointer to an CWTLSCertificate object.
williamr@2
   226
		Calling code can safely cast to CWTLSCertificate if using  "WSP/WSP".
williamr@2
   227
		NULL returned if certificate information not found.
williamr@2
   228
	*/
williamr@2
   229
	IMPORT_C const CCertificate* RHTTPSession::ServerCert();
williamr@2
   230
williamr@2
   231
	/** Connect this WSP session. This function does nothing when called for text-mode.
williamr@2
   232
	*/
williamr@2
   233
	//##ModelId=3C4C187B02A9
williamr@2
   234
	IMPORT_C void ConnectL();
williamr@2
   235
williamr@2
   236
	/** Disconnect this WSP session. This function does nothing when called for text-mode.
williamr@2
   237
	*/
williamr@2
   238
	//##ModelId=3C4C187B02A8
williamr@2
   239
	IMPORT_C void DisconnectL();
williamr@2
   240
	
williamr@2
   241
	/**Set the default Proxy for Http Session. This function reads default proxy information,if available, from CommsDat
williamr@2
   242
	and uses it for the current Session.
williamr@2
   243
	@internalAll
williamr@2
   244
	*/
williamr@2
   245
	IMPORT_C void SetupDefaultProxyFromCommsDatL();
williamr@2
   246
williamr@2
   247
	/**Sets the HTTP data optimiser for the session.
williamr@2
   248
	@param aHttpOptimiser An object of the implementation of interface, MHttpDataOptimiser, supplied by the client.
williamr@2
   249
	@publishedPartner
williamr@2
   250
	*/
williamr@2
   251
	IMPORT_C void SetupHttpDataOptimiser (MHttpDataOptimiser& aHttpOptimiser);
williamr@2
   252
 
williamr@2
   253
 	/**Returns the object of the MHttpDataOptimiser implementation class.
williamr@2
   254
	@internalTechnology
williamr@2
   255
	*/
williamr@2
   256
 	IMPORT_C MHttpDataOptimiser* HttpDataOptimiser ();
williamr@2
   257
williamr@2
   258
private:
williamr@2
   259
	friend class RHTTPFilterCollection;
williamr@2
   260
	friend class CHTTPSession;
williamr@2
   261
williamr@2
   262
	//##ModelId=3C4C187B0296
williamr@2
   263
	CHTTPSession* iImplementation;
williamr@2
   264
};
williamr@2
   265
williamr@2
   266
inline RHTTPSession::RHTTPSession()
williamr@2
   267
		: iImplementation(0)
williamr@2
   268
	{
williamr@2
   269
	}
williamr@2
   270
williamr@2
   271
williamr@2
   272
inline RHTTPFilterCollection RHTTPSession::FilterCollection() const
williamr@2
   273
	{
williamr@2
   274
	RHTTPFilterCollection c;
williamr@2
   275
	c.iImplementation = iImplementation;
williamr@2
   276
	return c;
williamr@2
   277
	}
williamr@2
   278
williamr@2
   279
inline TBool RHTTPSession::operator==(RHTTPSession aTrans) const
williamr@2
   280
	{
williamr@2
   281
	return (iImplementation == aTrans.iImplementation);
williamr@2
   282
	};
williamr@2
   283
inline TBool RHTTPSession::operator!=(RHTTPSession aTrans) const
williamr@2
   284
	{
williamr@2
   285
	return !(*this == aTrans);
williamr@2
   286
	};
williamr@2
   287
williamr@2
   288
williamr@2
   289
williamr@2
   290
inline RHTTPSession RHTTPFilterCollection::Session() const
williamr@2
   291
	{
williamr@2
   292
	RHTTPSession s;
williamr@2
   293
	s.iImplementation = iImplementation;
williamr@2
   294
	return s;
williamr@2
   295
	}
williamr@2
   296
williamr@2
   297
williamr@2
   298
williamr@2
   299
williamr@2
   300
#endif // __RHTTPSESSION_H__