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 __RHTTPTRANSACTION_H__
22 #define __RHTTPTRANSACTION_H__
25 #include <http/thttpevent.h>
26 #include <http/rhttpresponse.h>
27 #include <http/rhttprequest.h>
28 #include <http/rhttptransactionpropertyset.h>
29 #include <http/thttpfilterhandle.h>
30 #include <http/mhttpdataoptimiser.h>
32 // Forward declarations
33 class CHTTPTransaction;
35 class MHTTPTransactionCallback;
41 //##ModelId=3C4C18860091
42 class RHTTPTransaction
44 A HTTP Transaction. This encapsulates 1 HTTP request and
45 response. A Transaction is associated with a session, and must be
46 created using the session's CreateTransactionL method.
50 @see RHTTPSession::CreateTransactionL
55 Default (uninitialised) constructor
57 //##ModelId=3C4C188600F5
58 inline RHTTPTransaction();
60 /** Submits a transaction. Once all the headers and other details
61 have been set up, this call actualy causes the request to be
63 @leave KErrNoMemory There was not enough memory.
65 //##ModelId=3C4C188600ED
66 IMPORT_C void SubmitL(THTTPFilterHandle aStart =
67 THTTPFilterHandle::EClient);
69 IMPORT_C TInt Submit(THTTPFilterHandle aStart = THTTPFilterHandle::EClient);
70 /** Notify HTTP of the availability of more request body data,
71 when submitting body data in several parts.
73 @param aStart The filter supplying the new data. This will almost always be the client (default value)
74 @leave KErrNoMemory There was not enough memory.
76 //##ModelId=3C4C188600EB
77 IMPORT_C void NotifyNewRequestBodyPartL(THTTPFilterHandle aStart =
78 THTTPFilterHandle::EClient);
80 /** Sends a status message to all relevant filters. This function
81 is predominantly used by filters, rather than by the client.
82 @param aStatus The status message to send.
83 @param aDirection The direction down the filter queue that this event
85 @leave KErrNoMemory There was not enough memory.
87 //##ModelId=3C4C188600E2
88 IMPORT_C void SendEventL(THTTPEvent aStatus,
89 THTTPEvent::TDirection aDirection,
90 THTTPFilterHandle aStart);
92 IMPORT_C TInt SendEvent(THTTPEvent aStatus, THTTPEvent::TDirection aDirection, THTTPFilterHandle aStart);
93 /** Gets the response. Note that the returned response may not be
94 valid if it hasn't been created yet.
95 @see RHTTPMessage::IsValid()
97 //##ModelId=3C4C188600E1
98 IMPORT_C RHTTPResponse Response() const;
101 //##ModelId=3C4C188600DA
102 IMPORT_C RHTTPRequest Request() const;
104 // Returns the session associated with the transaction.
105 //##ModelId=3C4C188600D9
106 IMPORT_C RHTTPSession Session() const;
108 /** Returns the transaction's property set. This is used by filters
109 to store transaction-specific information, and by clients to
110 specify things like reload or no cache behaviour.
112 //##ModelId=3C4C188600D8
113 IMPORT_C RHTTPTransactionPropertySet PropertySet() const;
115 /** Cancels the transaction.
117 @param aStart The entity that is initiating the cancel (defaults
118 to the client). See THTTPFilterHandle for the values this can take.
120 //##ModelId=3C4C188600CF
121 IMPORT_C void Cancel(THTTPFilterHandle aStart =
122 THTTPFilterHandle::EClient);
124 /** Closes the transaction and frees all owned resources.
125 Transactions must be opened using RHTTPSession::OpenTransactionL.
126 It is also closed when you close the session.
128 //##ModelId=3C4C188600CE
129 IMPORT_C void Close();
131 /** This function should be called by filters when they have
132 failed due to running out of memory. It cancels the transaction
133 and sends the synchronous events EUnrecoverableError and EFailed
134 to the client to inform it of the failure. For instance in a
135 filter that attempts to send an event to the client from a
136 MHFRunError to inform the client of a failure, if the call to
137 SendEventL leaves, Fail() may be used to 'give up'. */
138 //##ModelId=3C4C188600C7
139 IMPORT_C void Fail(THTTPFilterHandle aStart =
140 THTTPFilterHandle::ECurrentFilter);
142 /** Equality operator to check if this transaction is the same as that one.
143 @param aTrans The transaction to compare this one to.
145 //##ModelId=3C4C188600C5
146 TBool operator==(RHTTPTransaction aTrans) const;
147 /** Inequality operator
148 @param aTrans The transaction to compare this one to.
150 //##ModelId=3C4C188600C3
151 TBool operator!=(RHTTPTransaction aTrans) const;
152 /** Obtain this transaction's ID, which is unique within its
153 session. This is mostly used for producing a
154 slightly-meaningful way of identifying transactions in logging
156 @return The transaction ID.
158 //##ModelId=3C4C188600BB
159 IMPORT_C TInt Id() const;
161 /** Obtain the server certificate information for this transaction. This function
162 should only be used for text-mode, for WSP use RHttpSession::ServerCert.
163 @see RHttpSession::ServerCert
164 @param aServerCert A client supplied object into which the certificate
165 information will be placed.
166 @return KErrNone if certificate has been completed, KErrNotSupported if
167 this function is called for WSP.
168 @deprecated v9.2 onwards - maintained for compatibility with v9.1 and before
169 TCertInfo has been deprecated since v9.2. CCertificate may be used as an alternative.
171 //##ModelId=3C4C188600B9
172 IMPORT_C TInt ServerCert(TCertInfo& aServerCert);
174 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
175 /** Obtain the server certificate information for this transaction. This function
176 should only be used for HTTP. WSP should use RHttpSession::ServerCert.
177 @see RHttpSession::ServerCert
179 @return a CCertificate pointer to an CX509Certificate object.
180 Calling code can safely cast to CX509Certificate if using "HTTP/TCP".
181 NULL returned if certificate information not found.
184 /** Obtain the server certificate information for this transaction. This function
185 should only be used for HTTP. WSP should use RHttpSession::ServerCert.
186 @see RHttpSession::ServerCert
189 @return a CCertificate pointer to an CX509Certificate object.
190 Calling code can safely cast to CX509Certificate if using "HTTP/TCP".
191 NULL returned if certificate information not found.
193 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS
194 IMPORT_C const CCertificate* ServerCert();
197 /** Obtain the cipher suite information for this transaction.
198 @return RString containing the cipher suite as per RFC2246.
200 IMPORT_C RString CipherSuite();
202 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
203 /**Sets the HTTP data optimiser for the transaction.
204 @param aHttpOptimiser An object of the implementation of interface, MHttpDataOptimiser, supplied by the client.
207 /**Sets the HTTP data optimiser for the transaction.
208 @param aHttpOptimiser An object of the implementation of interface, MHttpDataOptimiser, supplied by the client.
212 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS
213 IMPORT_C void SetupHttpDataOptimiser (MHttpDataOptimiser& aHttpOptimiser);
215 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
216 /**Returns the object of the MHttpDataOptimiser implementation class.
219 /**Returns the object of the MHttpDataOptimiser implementation class.
222 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS
223 IMPORT_C MHttpDataOptimiser* HttpDataOptimiser ();
226 friend class RHTTPSession;
227 friend class CTransaction;
228 friend class CProtocolHandler;
230 inline CTransaction* Implementation();
232 //##ModelId=3C4C188600A7
233 CTransaction* iImplementation;
236 inline TBool RHTTPTransaction::operator==(RHTTPTransaction aTrans) const
238 return (iImplementation == aTrans.iImplementation);
240 inline TBool RHTTPTransaction::operator!=(RHTTPTransaction aTrans) const
242 return !(*this == aTrans);
245 inline RHTTPTransaction::RHTTPTransaction()
246 : iImplementation(NULL)
250 inline CTransaction* RHTTPTransaction::Implementation()
252 return iImplementation;
255 #endif // __RHTTPTRANSACTION_H__