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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
19 @file RHTTPTransaction.h
20 @warning : This file contains Rose Model ID comments - please do not delete
23 #ifndef __RHTTPTRANSACTION_H__
24 #define __RHTTPTRANSACTION_H__
27 #include <http/thttpevent.h>
28 #include <http/rhttpresponse.h>
29 #include <http/rhttprequest.h>
30 #include <http/rhttptransactionpropertyset.h>
31 #include <http/thttpfilterhandle.h>
32 #include <http/mhttpdataoptimiser.h>
34 // Forward declarations
35 class CHTTPTransaction;
37 class MHTTPTransactionCallback;
43 //##ModelId=3C4C18860091
44 class RHTTPTransaction
46 A HTTP Transaction. This encapsulates 1 HTTP request and
47 response. A Transaction is associated with a session, and must be
48 created using the session's CreateTransactionL method.
52 @see RHTTPSession::CreateTransactionL
57 Default (uninitialised) constructor
59 //##ModelId=3C4C188600F5
60 inline RHTTPTransaction();
62 /** Submits a transaction. Once all the headers and other details
63 have been set up, this call actualy causes the request to be
65 @leave KErrNoMemory There was not enough memory.
67 //##ModelId=3C4C188600ED
68 IMPORT_C void SubmitL(THTTPFilterHandle aStart =
69 THTTPFilterHandle::EClient);
71 /** Notify HTTP of the availability of more request body data,
72 when submitting body data in several parts.
74 @param aStart The filter supplying the new data. This will almost always be the client (default value)
75 @leave KErrNoMemory There was not enough memory.
77 //##ModelId=3C4C188600EB
78 IMPORT_C void NotifyNewRequestBodyPartL(THTTPFilterHandle aStart =
79 THTTPFilterHandle::EClient);
81 /** Sends a status message to all relevant filters. This function
82 is predominantly used by filters, rather than by the client.
83 @param aStatus The status message to send.
84 @param aDirection The direction down the filter queue that this event
86 @leave KErrNoMemory There was not enough memory.
88 //##ModelId=3C4C188600E2
89 IMPORT_C void SendEventL(THTTPEvent aStatus,
90 THTTPEvent::TDirection aDirection,
91 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;
100 /// Gets the request.
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 /** Obtain the server certificate information for this transaction. This function
175 should only be used for HTTP. WSP should use RHttpSession::ServerCert.
176 @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.
183 IMPORT_C const CCertificate* ServerCert();
185 /** Obtain the cipher suite information for this transaction.
186 @return RString containing the cipher suite as per RFC2246.
188 IMPORT_C RString CipherSuite();
190 /**Sets the HTTP data optimiser for the transaction.
191 @param aHttpOptimiser An object of the implementation of interface, MHttpDataOptimiser, supplied by the client.
194 IMPORT_C void SetupHttpDataOptimiser (MHttpDataOptimiser& aHttpOptimiser);
196 /**Returns the object of the MHttpDataOptimiser implementation class.
199 IMPORT_C MHttpDataOptimiser* HttpDataOptimiser ();
202 friend class RHTTPSession;
203 friend class CTransaction;
206 //##ModelId=3C4C188600A7
207 CTransaction* iImplementation;
210 inline TBool RHTTPTransaction::operator==(RHTTPTransaction aTrans) const
212 return (iImplementation == aTrans.iImplementation);
214 inline TBool RHTTPTransaction::operator!=(RHTTPTransaction aTrans) const
216 return !(*this == aTrans);
219 inline RHTTPTransaction::RHTTPTransaction()
220 : iImplementation(NULL)
225 #endif // __RHTTPTRANSACTION_H__