1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
18 @warning : This file contains Rose Model ID comments - please do not delete
21 #ifndef __RHTTPSESSION_H__
22 #define __RHTTPSESSION_H__
27 #include <http/rhttpconnectioninfo.h>
28 #include <http/rhttpfiltercollection.h>
29 #include <http/rhttptransaction.h>
30 #include <http/mhttpdataoptimiser.h>
32 // Forward declarations
33 class MHTTPTransactionCallback;
35 class MHTTPSessionEventCallback;
36 class MHTTPFilterCreationCallback;
41 Constant to represent any HTTP Status code when registering filters.
45 const TInt KAnyStatusCode = -1;
48 //##ModelId=3C4C187B0280
51 A session handle. A session is a set of HTTP transactions using
52 the same connection settings (e.g. proxy) and the same set of filters.
53 Multi-homing support provided by HTTP framework enables clients to
54 specify Connection preferences through the session property
55 EHttpSocketConnection.
57 Note that RHTTPSession (and consequently the whole of HTTP)
58 depends on the active scheduler; a scheduler must be installed
59 when the session is opened and it must be running if a transaction
60 is actually to do anything.
68 @post The session is closed. (It must be opened with OpenL)
70 //##ModelId=3C4C187B02EF
71 inline RHTTPSession();
73 /** Sets the session event callback.
74 Until it is set all incoming session events are consumed
76 //##ModelId=3C4C187B02EA
77 IMPORT_C void SetSessionEventCallback(MHTTPSessionEventCallback* aSessionEventCallback);
79 /** Send an session event
80 @param aEvent. The session event to sent.
82 //##ModelId=3C4C187B02E6
83 IMPORT_C void SendSessionEventL(THTTPSessionEvent aStatus, THTTPSessionEvent::TDirection aDirection,
84 THTTPFilterHandle aStart = THTTPFilterHandle::EClient);
86 /** Fail the session event
88 IMPORT_C void FailSessionEvent(THTTPFilterHandle aStart = THTTPFilterHandle::EClient);
90 //##ModelId=3A49F701013F
91 /** Opens the session using the default protocol HTTP/TCP.
92 This function leaves with an apropriate code if the open failed.
93 @pre The session is closed. An active scheduler is installed.
94 @post The session is open.
96 //##ModelId=3C4C187B02DA
97 IMPORT_C void OpenL();
99 /** Opens the session using the protocol indicated by the parameter passed in.
100 This function leaves with an apropriate code if the open failed.
101 @param aProtocol The protocol required
102 @pre The session is closed. An active scheduler is installed.
103 @post The session is open.
105 //##ModelId=3C4C187B02DB
106 IMPORT_C void OpenL(const TDesC8& aProtocol);
108 /** Opens the session using the protocol indicated by the parameter passed in.
109 This method should be used if configuring the installed filters is required.
110 Once construction if the session is complete the callback method passed in is
111 called passing in a TFilterConfigurationIterator to allow the filters that
112 are installed to be configured.
113 This function leaves with an apropriate code if the open failed.
114 @param aProtocol The protocol required
115 @param aSessionCallback The pointer to the object providing the call back method
116 @pre The session is closed. An active scheduler is installed.
117 @post The session is open.
119 //##ModelId=3C4C187B02DD
120 IMPORT_C void OpenL(const TDesC8& aProtocol, MHTTPFilterCreationCallback* aSessionCallback);
122 /** This is a static methods that lists all the available protocols by adding the
123 prorocol descriptors to the descriptor array passed in. Any existing data in the
124 descriptor array passed in is deleted.
125 This function leaves if the descriptor array can not be updated with the appropriate
127 @param aProtocolArray A pointer array to heap based descriptors. The data in this
128 array will be deleted and filled with descriptors containing the available protocols
131 //##ModelId=3C4C187B02D4
132 IMPORT_C static void ListAvailableProtocolsL(RPointerArray<HBufC8>& aProtocolArray);
134 /** Creates a transaction.
135 @pre The session is open
136 @param aURI The URI that the request will be sent to.
137 @param aCallback A callback for all status events relating to
139 @param aMethod The HTTP method to use (default: GET)
140 @leave KErrNoMemory There was not enough memory.
142 //##ModelId=3C4C187B02D0
143 IMPORT_C RHTTPTransaction OpenTransactionL(const TUriC8& aURI,
144 MHTTPTransactionCallback& aCallback,
145 RStringF aMethod = RStringF());
147 /** Closes the session. All transactions will be stopped and closed
148 @post The session and all open transactions in it are closed.
150 //##ModelId=3C4C187B02C8
151 IMPORT_C void Close();
154 //##ModelId=3C4C187B02C7
155 IMPORT_C static const TStringTable& GetTable();
157 /** Accessor for the HTTP string pool.
158 @return A handle for the string pool used in HTTP.
160 //##ModelId=3C4C187B02C6
161 IMPORT_C RStringPool StringPool() const;
163 /** Accessor for the connection info for this session, and which
164 is used for all transactions in the session. Note that by and
165 large, the connection info should be set up before the first
166 transaction is created. @return A handle to the connection
168 //##ModelId=3C4C187B02BE
169 IMPORT_C RHTTPConnectionInfo ConnectionInfo() const;
171 /** Accessor for the filter collection. Note that the filter
172 collection can't be edited after the first transaction has
174 //##ModelId=3C4C187B02BD
175 inline RHTTPFilterCollection FilterCollection() const;
178 /** Accessor for the session headers. These are headers that will get added to each request
179 They only become part of the transaction headers when a transaction is submitted and they will not
180 replace headers that already exist in the transaction request
182 //##ModelId=3C4C187B02BC
183 IMPORT_C RHTTPHeaders RequestSessionHeadersL();
186 /** Accessor for the response session headers. These are headers that will get added to each response if the
187 corresponding header doesn't already exist
189 //##ModelId=3C4C187B02B6
190 IMPORT_C RHTTPHeaders ResponseSessionHeadersL();
192 /** Equality operator.
193 @param aTrans The session to compare this one to.
195 //##ModelId=3C4C187B02B4
196 TBool operator==(RHTTPSession aTrans) const;
197 /** Inequality operator
198 @param aTrans The session to compare this one to.
201 //##ModelId=3C4C187B02B2
202 TBool operator!=(RHTTPSession aTrans) const;
204 /** Obtain the server certificate information for this session. This function
205 should only be used for WSP, for text-mode use RHttpTransaction::ServerCert.
206 @see RHttpTransaction::ServerCert
207 @param aServerCert A client supplied object into which the certificate
208 information will be placed.
209 @return KErrNone if certificate has been completed, KErrNotSupported if
210 this function is called for text-mode.
211 @deprecated v9.2 onwards - maintained for compatibility with v9.1 and before
212 TCertInfo has been deprecated since v9.2. CCertificate may be used as an alternative.
214 //##ModelId=3C4C187B02AA
215 IMPORT_C TInt ServerCert(TCertInfo& aServerCert);
217 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
218 /** Obtain the server certificate information for this session. This function
219 should only be used for WSP. HTTP should use RHttpTransaction::ServerCert.
220 @see RHttpSession::ServerCert
222 @return a CCertificate pointer to an CWTLSCertificate object.
223 Calling code can safely cast to CWTLSCertificate if using "WSP/WSP".
224 NULL returned if certificate information not found.
227 /** Obtain the server certificate information for this session. This function
228 should only be used for WSP. HTTP should use RHttpTransaction::ServerCert.
229 @see RHttpSession::ServerCert
232 @return a CCertificate pointer to an CWTLSCertificate object.
233 Calling code can safely cast to CWTLSCertificate if using "WSP/WSP".
234 NULL returned if certificate information not found.
236 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS
237 IMPORT_C const CCertificate* ServerCert();
239 /** Connect this WSP session. This function does nothing when called for text-mode.
241 //##ModelId=3C4C187B02A9
242 IMPORT_C void ConnectL();
244 /** Disconnect this WSP session. This function does nothing when called for text-mode.
246 //##ModelId=3C4C187B02A8
247 IMPORT_C void DisconnectL();
249 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
250 /**Set the default Proxy for Http Session. This function reads default proxy information,if available, from CommsDat
251 and uses it for the current Session.
254 IMPORT_C void SetupDefaultProxyFromCommsDatL();
256 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS
258 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
259 /**Sets the HTTP data optimiser for the session.
260 @param aHttpOptimiser An object of the implementation of interface, MHttpDataOptimiser, supplied by the client.
263 /**Sets the HTTP data optimiser for the session.
264 @param aHttpOptimiser An object of the implementation of interface, MHttpDataOptimiser, supplied by the client.
268 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS
269 IMPORT_C void SetupHttpDataOptimiser (MHttpDataOptimiser& aHttpOptimiser);
271 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
272 /**Returns the object of the MHttpDataOptimiser implementation class.
275 /**Returns the object of the MHttpDataOptimiser implementation class.
278 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS
279 IMPORT_C MHttpDataOptimiser* HttpDataOptimiser ();
282 friend class RHTTPFilterCollection;
283 friend class CHTTPSession;
285 //##ModelId=3C4C187B0296
286 CHTTPSession* iImplementation;
289 inline RHTTPSession::RHTTPSession()
295 inline RHTTPFilterCollection RHTTPSession::FilterCollection() const
297 RHTTPFilterCollection c;
298 c.iImplementation = iImplementation;
302 inline TBool RHTTPSession::operator==(RHTTPSession aTrans) const
304 return (iImplementation == aTrans.iImplementation);
306 inline TBool RHTTPSession::operator!=(RHTTPSession aTrans) const
308 return !(*this == aTrans);
313 inline RHTTPSession RHTTPFilterCollection::Session() const
316 s.iImplementation = iImplementation;
323 #endif // __RHTTPSESSION_H__