|
1 /* |
|
2 * Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 #include <uri8.h> |
|
29 #include <es_sock.h> |
|
30 #include <in_sock.h> |
|
31 #include <http.h> |
|
32 |
|
33 #include "sendebug.h" // filelogging and debugging MACROS |
|
34 #include <SenServiceConnection.h> // KErrSenNoHttpResponseBody |
|
35 #include <SenElement.h> |
|
36 #include <SenXmlUtils.h> |
|
37 #include <SenHttpTransportProperties.h> |
|
38 #include "senhttpchannelimpl.h" |
|
39 #include "senhttpeventhandler.h" |
|
40 #include "sentxnstate.h" |
|
41 #include "senatomtxnstate.h" |
|
42 #include "senrfiletxnstate.h" |
|
43 #include "senhttpchannel.h" |
|
44 #include "senlayeredhttptransportproperties.h" |
|
45 #include "msenidentitymanager.h" |
|
46 #include "senlogger.h" |
|
47 |
|
48 #include "senhttpchanneltransportplugin.h" |
|
49 //For HTTPProxyFilter |
|
50 #include <HttpFilterProxyInterface.h> |
|
51 #include <HttpFilterAcceptHeaderInterface.h> |
|
52 #include <HttpFilterCommonStringsExt.h> |
|
53 #include <DeflateFilterInterface.h> |
|
54 |
|
55 // CONSTANTS |
|
56 namespace |
|
57 { |
|
58 _LIT(KTxnStateNullPanicText, "TxnState is NULL"); |
|
59 |
|
60 // Minimum granularity for array initialization |
|
61 const TInt KMinimumArrayGranularity = 1; |
|
62 |
|
63 #ifdef _SENDEBUG |
|
64 // logging constants |
|
65 //_LIT(KLogFileDir, "SenHttpChannel"); |
|
66 // _LIT(KLogFileName, "SenHttpChannel.log"); |
|
67 _LIT(KDateFormat,"%D%M%Y%/0%1%/1%2%/2%3%/3 %:0%H%:1%T%:2%S.%C%:3"); |
|
68 // Size of buffer used when submitting request bodies |
|
69 const TInt KMaxHeaderNameLen = 16; |
|
70 const TInt KMaxHeaderValueLen = 128; |
|
71 const TInt KMaxFilterNameLen = 16; |
|
72 #endif |
|
73 } |
|
74 |
|
75 // |
|
76 // Implementation of CSenHttpChannelImpl |
|
77 // |
|
78 CSenHttpChannelImpl::CSenHttpChannelImpl(MSenIdentityManager& aManager) |
|
79 : |
|
80 iIapId(KErrNone), |
|
81 iManager(aManager), |
|
82 iSessionAuthentication(NULL), |
|
83 iPasswordFromUser(EFalse), |
|
84 iExplicitIapDefined(EFalse), |
|
85 iProxyHostPort(NULL), |
|
86 iXopResponse(EFalse), |
|
87 iHasHttpContentType(ETrue) |
|
88 { |
|
89 } |
|
90 |
|
91 CSenHttpChannelImpl* CSenHttpChannelImpl::NewL(MSenIdentityManager& aManager) |
|
92 { |
|
93 CSenHttpChannelImpl* pNew = NewLC(aManager); |
|
94 CleanupStack::Pop(pNew); |
|
95 return pNew; |
|
96 } |
|
97 |
|
98 CSenHttpChannelImpl* CSenHttpChannelImpl::NewLC(MSenIdentityManager& aManager) |
|
99 { |
|
100 CSenHttpChannelImpl* pNew = new (ELeave) CSenHttpChannelImpl(aManager); |
|
101 CleanupStack::PushL(pNew); |
|
102 pNew->ConstructL(); |
|
103 return pNew; |
|
104 } |
|
105 |
|
106 CSenHttpChannelImpl* CSenHttpChannelImpl::NewL(MSenIdentityManager& aManager, |
|
107 TUint32 aIapId) |
|
108 { |
|
109 CSenHttpChannelImpl* pNew = NewLC(aManager, aIapId); |
|
110 CleanupStack::Pop(pNew); |
|
111 return pNew; |
|
112 } |
|
113 |
|
114 CSenHttpChannelImpl* CSenHttpChannelImpl::NewLC(MSenIdentityManager& aManager, |
|
115 TUint32 aIapId) |
|
116 { |
|
117 CSenHttpChannelImpl* pNew = new (ELeave) CSenHttpChannelImpl(aManager); |
|
118 CleanupStack::PushL(pNew); |
|
119 pNew->ConstructL(aIapId); |
|
120 return pNew; |
|
121 } |
|
122 |
|
123 // Ask IAP from user |
|
124 void CSenHttpChannelImpl::ConstructL() |
|
125 { |
|
126 // Open connection to the file logger server |
|
127 TLSLOG_OPEN(KSenHttpChannelLogChannelBase, KSenHttpChannelLogLevel, KSenHttpChannelLogDir, KSenHttpChannelLogFile); |
|
128 TLSLOG(KSenHttpChannelLogChannelBase , KMinLogLevel,(_L("CSenHttpChannelImpl::ConstructL - Log file opened"))); |
|
129 |
|
130 // Open the RHTTPSession |
|
131 TLSLOG(KSenHttpChannelLogChannelBase , KMinLogLevel,(_L("- Opening HTTP/TCP session."))); |
|
132 |
|
133 iSess.OpenL(); |
|
134 |
|
135 // Store the string pool for this HTTP session |
|
136 iStringPool = iSess.StringPool(); |
|
137 |
|
138 // Install this class as the callback for authentication requests |
|
139 InstallAuthenticationL( iSess ); |
|
140 //Install Proxy Filter |
|
141 iDeflateFilter = EFalse; |
|
142 |
|
143 #ifdef EKA2 |
|
144 //#ifndef _DEBUG |
|
145 CHttpFilterProxyInterface::InstallFilterL( iSess ); |
|
146 iSess.StringPool().OpenL(HttpFilterCommonStringsExt::GetLanguageTable()); |
|
147 iSess.StringPool().OpenL(HttpFilterCommonStringsExt::GetTable()); |
|
148 |
|
149 CHttpFilterAcceptHeaderInterface::InstallFilterL(iSess); |
|
150 TLSLOG_L(KSenHttpChannelLogChannelBase , KNormalLogLevel,"HTTPProxyFilter installed for EKA2 build."); |
|
151 TLSLOG_L(KSenHttpChannelLogChannelBase , KNormalLogLevel,"HTTPAcceptFilter installed for EKA2 build."); |
|
152 //#else |
|
153 // LOG_WRITE_L("HTTPProxyFilter is NOT in use with EKA2 debug builds."); |
|
154 //#endif |
|
155 #else // __INSTALL_HTTP_PROXY_FILTER__ is not defined by macro in .mmp |
|
156 TLSLOG_L(KSenHttpChannelLogChannelBase , KNormalLogLevel,"HTTPProxyFilter is NOT in use with EKA1."); |
|
157 TLSLOG_L(KSenHttpChannelLogChannelBase , KNormalLogLevel,"HTTPAcceptProxyFilter is NOT in use with EKA1."); |
|
158 #endif // __INSTALL_HTTP_PROXY_FILTER__ |
|
159 |
|
160 iTransObs = CSenHttpEventHandler::NewL(this);//, &iLog); |
|
161 iTxnStates = |
|
162 new (ELeave) CArrayPtrFlat<CSenTxnState>(KMinimumArrayGranularity); |
|
163 |
|
164 iBasicConnectionTries = 0; |
|
165 |
|
166 #ifdef _SENDEBUG |
|
167 ListFilters(); |
|
168 #endif // _SENDEBUG |
|
169 } |
|
170 |
|
171 // Forces preselected IAP to be used! |
|
172 void CSenHttpChannelImpl::ConstructL( TUint32 aIapId ) |
|
173 { |
|
174 // Initialize |
|
175 // SetupConnectionWithIapPrefsL( aIapId, iConnection, iSockServ ); |
|
176 |
|
177 ConstructL(); |
|
178 |
|
179 // AttachSocketServerAndConnectionWithHttpSession( aIapId, iConnection, iSockServ ); |
|
180 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"CSenHttpChannelImpl::ConstructL - Setting IAP id"); |
|
181 |
|
182 |
|
183 // Use local variable (new RSocketServer each time; handle is given to RHTTPSession via RConnectionInfo..) |
|
184 // RSocketServ server; // with "anon" (local) socket servers, should we keep array of open ones in case of pending txns? |
|
185 // SetIapPrefsL(aIapId, iConnection, server); |
|
186 |
|
187 const TInt result = SetIapPrefsL(aIapId, ETrue, iConnection, iSockServ); |
|
188 User::LeaveIfError( result ); |
|
189 |
|
190 } |
|
191 |
|
192 CSenHttpChannelImpl::~CSenHttpChannelImpl() |
|
193 { |
|
194 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"CSenHttpChannelImpl::~CSenHttpChannelImpl()"); |
|
195 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"Closing http session."); |
|
196 iSess.Close(); |
|
197 if (iTransObs) //might be NULL if constructor failed --- |
|
198 { |
|
199 delete iTransObs; |
|
200 iTransObs = NULL; |
|
201 } |
|
202 if (iTxnStates) //might be NULL if constructor failed--- |
|
203 { |
|
204 iTxnStates->ResetAndDestroy(); |
|
205 delete iTxnStates; |
|
206 iTxnStates = NULL; |
|
207 } |
|
208 |
|
209 if(iProxyHostPort) |
|
210 { |
|
211 delete iProxyHostPort; |
|
212 iProxyHostPort = NULL; |
|
213 } |
|
214 |
|
215 if(iMultiPartContentType.params.Count()) |
|
216 { |
|
217 iMultiPartContentType.params.Close(); |
|
218 } |
|
219 if(iDeflateFilter) |
|
220 { |
|
221 REComSession::DestroyedImplementation(KDeflateFilterUid); |
|
222 } |
|
223 |
|
224 iConnection.Close(); |
|
225 iSockServ.Close(); |
|
226 |
|
227 // Close the log file and the connection to the server. |
|
228 TLSLOG(KSenHttpChannelLogChannelBase , KMinLogLevel,(_L("Log file closed."))); |
|
229 TLSLOG_CLOSE(KSenHttpChannelLogChannelBase); |
|
230 } |
|
231 |
|
232 // This function expects that RConnection has been connected |
|
233 // and that RConnection has already been opened! |
|
234 /* |
|
235 void CSenHttpChannelImpl::SetIapPrefsL(TUint32 aIapId, |
|
236 RConnection& aConnection, |
|
237 RSocketServ& aSocketServer) |
|
238 { |
|
239 // Check whether IAP ID is not equal with the one that is currently in effect: |
|
240 if(iExplicitIapDefined && iIapId == aIapId ) |
|
241 { |
|
242 return; // nothing to do |
|
243 } |
|
244 |
|
245 LOG_WRITEFORMAT((_L8("- SetIapPrefsL: Re-setting IAP ID (%d)"), aIapId)); |
|
246 |
|
247 // Check if socket server (connection) is already open.. |
|
248 if( iExplicitIapDefined ) |
|
249 { |
|
250 // Socket server opened once before for some other IAP |
|
251 LOG_WRITE_L("- SetIapPrefsL: Re-using existing RConnection => calling RConnection::Stop"); |
|
252 aConnection.Stop(); |
|
253 } |
|
254 else |
|
255 { |
|
256 aConnection.Stop(); // prompted from user |
|
257 iSess.DisconnectL(); |
|
258 iSess.ConnectL(); |
|
259 |
|
260 // Connect to a socket server |
|
261 LOG_WRITE_L("- SetIapPrefsL: Connecting to new socket server"); |
|
262 User::LeaveIfError(aSocketServer.Connect()); |
|
263 |
|
264 // Open new connection |
|
265 LOG_WRITE_L("- SetIapPrefsL: Opening new RConnection using the socket server."); |
|
266 User::LeaveIfError(aConnection.Open(aSocketServer)); |
|
267 } |
|
268 |
|
269 // Set the IAP selection preferences (IAP ID, do not prompt) |
|
270 TCommDbConnPref pref; |
|
271 pref.SetIapId( aIapId ); |
|
272 |
|
273 TCommDbDialogPref dialogPref; |
|
274 dialogPref = ECommDbDialogPrefDoNotPrompt; |
|
275 pref.SetDialogPreference(dialogPref); |
|
276 |
|
277 // Start the connection with the new preferences |
|
278 LOG_WRITE_L("- SetIapPrefsL: Calling RConnection::Start with new IAP prefs"); |
|
279 aConnection.Start(pref); |
|
280 |
|
281 // Get the connection "handle" from the HTTP session |
|
282 RHTTPConnectionInfo connInfo = iSess.ConnectionInfo(); |
|
283 |
|
284 // Attach socket server |
|
285 connInfo.SetPropertyL(iStringPool.StringF( HTTP::EHttpSocketServ, |
|
286 RHTTPSession::GetTable()), |
|
287 THTTPHdrVal(aSocketServer.Handle())); |
|
288 |
|
289 // Attach connection |
|
290 TInt connPtr = REINTERPRET_CAST(TInt, &aConnection); |
|
291 connInfo.SetPropertyL(iStringPool.StringF( HTTP::EHttpSocketConnection, |
|
292 RHTTPSession::GetTable()), |
|
293 THTTPHdrVal(connPtr)); |
|
294 |
|
295 // Remember the IAP id that is being set; there is |
|
296 // no direct API to query effective IAP ID from CommsDB. |
|
297 iExplicitIapDefined = ETrue; |
|
298 iIapId = aIapId; |
|
299 } |
|
300 */ |
|
301 |
|
302 |
|
303 /* |
|
304 void CSenHttpChannelImpl::SetupConnectionWithIapPrefsL( TUint32 aIapId, |
|
305 RConnection& aConnection, |
|
306 RSocketServ& aSocketServer ) |
|
307 { |
|
308 // Check whether IAP ID is not equal with the one that is currently in effect: |
|
309 if(iExplicitIapDefined && iIapId == aIapId ) |
|
310 { |
|
311 return; // nothing to do |
|
312 } |
|
313 |
|
314 LOG_WRITEFORMAT((_L8("- SetIapPrefsL, IAP ID (%d)"), aIapId)); |
|
315 |
|
316 // Check if socket server (connection) is already open.. |
|
317 if( iExplicitIapDefined ) |
|
318 { |
|
319 // Socket server opened once before for some other IAP |
|
320 LOG_WRITE_L("- SetIapPrefsL: Re-using existing RConnection => calling RConnection::Stop"); |
|
321 aConnection.Stop(); |
|
322 } |
|
323 else |
|
324 { |
|
325 // Connect to a socket server |
|
326 LOG_WRITE_L("- SetIapPrefsL: Connecting to new socket server"); |
|
327 User::LeaveIfError( aSocketServer.Connect() ); |
|
328 |
|
329 // Open new connection |
|
330 LOG_WRITE_L("- SetIapPrefsL: Opening new RConnection using the socket server."); |
|
331 User::LeaveIfError( aConnection.Open(aSocketServer) ); |
|
332 } |
|
333 |
|
334 // Set the IAP selection preferences (IAP ID, do not prompt) |
|
335 TCommDbConnPref pref; |
|
336 pref.SetIapId( aIapId ); |
|
337 |
|
338 TCommDbDialogPref dialogPref; |
|
339 dialogPref = ECommDbDialogPrefDoNotPrompt; |
|
340 pref.SetDialogPreference(dialogPref); |
|
341 |
|
342 // Start the connection with the new preferences |
|
343 LOG_WRITE_L("- SetIapPrefsL: Calling RConnection::Start with new IAP prefs"); |
|
344 aConnection.Start(pref); |
|
345 } |
|
346 |
|
347 |
|
348 void CSenHttpChannelImpl::AttachSocketServerAndConnectionWithHttpSession( TUint32 aIapId, |
|
349 RConnection& aConnection, |
|
350 RSocketServ& aSocketServer ) |
|
351 { |
|
352 if(iExplicitIapDefined && iIapId == aIapId ) |
|
353 { |
|
354 return; // nothing to do |
|
355 } |
|
356 |
|
357 // Get the connection "handle" from the HTTP session |
|
358 RHTTPConnectionInfo connInfo = iSess.ConnectionInfo(); |
|
359 |
|
360 // Attach socket server |
|
361 connInfo.SetPropertyL(iStringPool.StringF( HTTP::EHttpSocketServ, |
|
362 RHTTPSession::GetTable()), |
|
363 THTTPHdrVal(aSocketServer.Handle())); |
|
364 |
|
365 // Attach connection |
|
366 TInt connPtr = REINTERPRET_CAST(TInt, &aConnection); |
|
367 connInfo.SetPropertyL(iStringPool.StringF( HTTP::EHttpSocketConnection, |
|
368 RHTTPSession::GetTable()), |
|
369 THTTPHdrVal(connPtr)); |
|
370 |
|
371 // Remember the IAP id that is being set, because *at the moment*, |
|
372 // there is NO direct API to query effective IAP ID from CommsDB. |
|
373 iExplicitIapDefined = ETrue; |
|
374 iIapId = aIapId; |
|
375 } |
|
376 |
|
377 |
|
378 void CSenHttpChannelImpl::SetIapPrefsL( TUint32 aIapId, RConnection& aConnection, RSocketServ& aSocketServer ) |
|
379 { |
|
380 SetupConnectionWithIapPrefsL( aIapId, aConnection, aSocketServer ); |
|
381 AttachSocketServerAndConnectionWithHttpSession( aIapId, aConnection, aSocketServer ); |
|
382 } |
|
383 */ |
|
384 |
|
385 |
|
386 TInt CSenHttpChannelImpl::SetIapPrefsL( TUint32 aIapId, TBool aDialogPref, RConnection& aConnection, RSocketServ& aSocketServer ) |
|
387 { |
|
388 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KNormalLogLevel, _L8("- SetIapPrefsL, IAP ID (%d)"), aIapId)); |
|
389 |
|
390 // Check whether IAP ID is not equal with the one that is currently in effect: |
|
391 if(iExplicitIapDefined && iIapId == aIapId ) |
|
392 { |
|
393 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetIapPrefsL: Iap Id is same as currently in effect"); |
|
394 return KErrNone; |
|
395 } |
|
396 else |
|
397 { |
|
398 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetIapPrefsL: Iap Id different with the currently in effect"); |
|
399 } |
|
400 |
|
401 |
|
402 // Check if socket server (connection) is already open.. |
|
403 if( iExplicitIapDefined ) |
|
404 { |
|
405 // Socket server opened once before for some other IAP |
|
406 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetIapPrefsL: Re-using existing RConnection => calling RConnection::Stop"); |
|
407 aConnection.Stop(); |
|
408 } |
|
409 else |
|
410 { |
|
411 // Connect to a socket server |
|
412 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetIapPrefsL: Connecting to new socket server"); |
|
413 User::LeaveIfError( aSocketServer.Connect() ); |
|
414 |
|
415 // Open new connection |
|
416 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetIapPrefsL: Opening new RConnection using the socket server."); |
|
417 User::LeaveIfError( aConnection.Open(aSocketServer) ); |
|
418 } |
|
419 |
|
420 // Set the IAP selection preferences (IAP ID, do not prompt) |
|
421 /* |
|
422 /*Single click connectivity feature has been implemented by CSock (RConnection class). |
|
423 /*According to this client no need to set the IAP ID. |
|
424 /*Automatically RConnection will use the suitable IAP |
|
425 */ |
|
426 |
|
427 |
|
428 TCommDbConnPref pref; |
|
429 #ifndef __SINGLE_CLICK_CONNECTIVITY_ENABLED__ |
|
430 pref.SetIapId( aIapId ); |
|
431 #else |
|
432 pref.SetIapId( 0 ); //By default IAP ID is "0". IAP selection will take care by RConnection |
|
433 #endif //__SINGLE_CLICK_CONNECTIVITY_ENABLED__ |
|
434 TCommDbDialogPref dialogPref; |
|
435 |
|
436 if (aDialogPref) |
|
437 { |
|
438 dialogPref = ECommDbDialogPrefDoNotPrompt; |
|
439 } |
|
440 else |
|
441 { |
|
442 dialogPref = ECommDbDialogPrefPrompt; |
|
443 } |
|
444 pref.SetDialogPreference(dialogPref); |
|
445 |
|
446 // Start the connection with the new preferences |
|
447 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetIapPrefsL: Calling RConnection::Start with new IAP prefs"); |
|
448 |
|
449 TInt retVal =aConnection.Start(pref); |
|
450 |
|
451 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("RConnection->Start retVal [%d]"), retVal)); |
|
452 |
|
453 // Get the connection "handle" from the HTTP session |
|
454 RHTTPConnectionInfo connInfo = iSess.ConnectionInfo(); |
|
455 |
|
456 // Attach socket server |
|
457 connInfo.SetPropertyL(iStringPool.StringF( HTTP::EHttpSocketServ, |
|
458 RHTTPSession::GetTable()), |
|
459 THTTPHdrVal(aSocketServer.Handle())); |
|
460 |
|
461 // Attach connection |
|
462 TInt connPtr = REINTERPRET_CAST(TInt, &aConnection); |
|
463 connInfo.SetPropertyL(iStringPool.StringF( HTTP::EHttpSocketConnection, |
|
464 RHTTPSession::GetTable()), |
|
465 THTTPHdrVal(connPtr)); |
|
466 |
|
467 // Remember the IAP id that is being set, because *at the moment*, |
|
468 // there is NO direct API to query effective IAP ID from CommsDB. |
|
469 if (!retVal) |
|
470 { |
|
471 iExplicitIapDefined = ETrue; |
|
472 iIapId = aIapId; |
|
473 } |
|
474 return retVal; |
|
475 } |
|
476 TInt CSenHttpChannelImpl::SetSnapPrefsL( TUint32 aSnapId, TBool aDialogPref, RConnection& aConnection, RSocketServ& aSocketServer ) |
|
477 { |
|
478 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("- CSenHttpChannelImpl::SetSnapPrefsL, SNAP ID (%d)"), aSnapId)); |
|
479 // Check whether SNAP ID is not equal with the one that is currently in effect: |
|
480 if(iExplicitIapDefined && iSnapId == aSnapId ) |
|
481 { |
|
482 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetSnapPrefsL: Sanp is same as currently in effect"); |
|
483 return KErrNone; |
|
484 } |
|
485 else |
|
486 { |
|
487 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetSnapPrefsL: Sanp is different with currently in effect"); |
|
488 } |
|
489 |
|
490 // Check if socket server (connection) is already open.. |
|
491 if( iExplicitIapDefined ) |
|
492 { |
|
493 // Socket server opened once before for some other IAP |
|
494 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetSnapPrefsL: Re-using existing RConnection => calling RConnection::Stop"); |
|
495 aConnection.Stop(); |
|
496 } |
|
497 else |
|
498 { |
|
499 // Connect to a socket server |
|
500 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetSnapPrefsL: Connecting to new socket server"); |
|
501 User::LeaveIfError( aSocketServer.Connect() ); |
|
502 |
|
503 // Open new connection |
|
504 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetSnapPrefsL: Opening new RConnection using the socket server."); |
|
505 User::LeaveIfError( aConnection.Open(aSocketServer) ); |
|
506 } |
|
507 |
|
508 // Set the SNAP selection preferences (SNAP ID) |
|
509 TConnSnapPref pref; |
|
510 pref.SetSnap(aSnapId); |
|
511 |
|
512 // Start the connection with the new preferences |
|
513 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- SetSnapPrefsL: Calling RConnection::Start with new SNAP prefs"); |
|
514 TInt retVal = aConnection.Start(pref); |
|
515 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("- SetSnapPrefsL, RConnection::Start returned: (%d)"), retVal)); |
|
516 |
|
517 // Get the connection "handle" from the HTTP session |
|
518 RHTTPConnectionInfo connInfo = iSess.ConnectionInfo(); |
|
519 |
|
520 // Attach socket server |
|
521 connInfo.SetPropertyL(iStringPool.StringF( HTTP::EHttpSocketServ, |
|
522 RHTTPSession::GetTable()), |
|
523 THTTPHdrVal(aSocketServer.Handle())); |
|
524 |
|
525 // Attach connection |
|
526 TInt connPtr = REINTERPRET_CAST(TInt, &aConnection); |
|
527 connInfo.SetPropertyL(iStringPool.StringF( HTTP::EHttpSocketConnection, |
|
528 RHTTPSession::GetTable()), |
|
529 THTTPHdrVal(connPtr)); |
|
530 |
|
531 // Remember the SNAP id that is being set, because *at the moment*, |
|
532 // there is NO direct API to query effective SNAP ID from CommsDB. |
|
533 if (!retVal) |
|
534 { |
|
535 iExplicitIapDefined = ETrue; |
|
536 iSnapId = aSnapId; |
|
537 } |
|
538 return retVal; |
|
539 } |
|
540 |
|
541 TInt CSenHttpChannelImpl::SendL( MSenResponseObserver& aObserver, |
|
542 const TDesC8& aUri, |
|
543 const TDesC8& aContent, |
|
544 CSenLayeredHttpTransportProperties& aProps ) |
|
545 { |
|
546 #ifdef _SENDEBUG |
|
547 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"CSenHttpChannelImpl::SendL:"); |
|
548 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("- Endpoint URI: %S"), &aUri)); |
|
549 TLSLOG_L(KSenHttpChannelLogChannelBase , KMaxLogLevel,"- Content(msg):"); |
|
550 TLSLOG_ALL(KSenHttpChannelLogChannelBase , KMaxLogLevel,(aContent)); |
|
551 #endif |
|
552 |
|
553 TPtrC8 contentType; |
|
554 TInt retVal = aProps.ContentTypeL(contentType); |
|
555 if(retVal!=KErrNone) |
|
556 { |
|
557 // Use the default |
|
558 contentType.Set(KDefaultContentType); |
|
559 } |
|
560 |
|
561 CSenTxnState* pTxnState = CSenTxnState::NewL(aObserver, |
|
562 //Log(), |
|
563 &aUri, |
|
564 contentType, |
|
565 &aContent); |
|
566 |
|
567 CleanupStack::PushL(pTxnState); |
|
568 AppendNewTxnStateL(pTxnState); |
|
569 CleanupStack::Pop(); // pTxnState |
|
570 |
|
571 return InvokeHttpMethodL(pTxnState, aProps); |
|
572 } |
|
573 |
|
574 TInt CSenHttpChannelImpl::SendL( MSenResponseObserver& aObserver, |
|
575 const TDesC8& aUri, |
|
576 const RFile& aFile, |
|
577 CSenLayeredHttpTransportProperties& aProps ) |
|
578 { |
|
579 #ifdef _SENDEBUG |
|
580 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"CSenHttpChannelImpl::SendL:"); |
|
581 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("- Endpoint URI: %S"), &aUri)); |
|
582 TLSLOG_L(KSenHttpChannelLogChannelBase , KMaxLogLevel,"- Content(msg):"); |
|
583 #endif |
|
584 |
|
585 TPtrC8 contentType; |
|
586 TInt retVal = aProps.ContentTypeL(contentType); |
|
587 if(retVal != KErrNone) |
|
588 { |
|
589 // Use the default |
|
590 contentType.Set(KDefaultContentType); |
|
591 } |
|
592 |
|
593 CSenRfileTxnState* pTxnState = CSenRfileTxnState::NewL(aObserver, |
|
594 //Log(), |
|
595 &aUri, |
|
596 this, |
|
597 contentType, |
|
598 aFile); |
|
599 |
|
600 CleanupStack::PushL(pTxnState); |
|
601 AppendNewTxnStateL(pTxnState); |
|
602 CleanupStack::Pop(); // pTxnState |
|
603 |
|
604 return InvokeHttpMethodL(pTxnState, aProps); |
|
605 } |
|
606 |
|
607 |
|
608 TInt CSenHttpChannelImpl::SendL(MSenResponseObserver& aObserver, |
|
609 const TDesC8& aUri, |
|
610 CSenSoapEnvelope2& aContent, |
|
611 CSenLayeredHttpTransportProperties& aProps) |
|
612 { |
|
613 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"CSenHttpChannelImpl::SendL:"); |
|
614 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("- Endpoint URI: %S"), &aUri)); |
|
615 |
|
616 TPtrC8 soapAction; |
|
617 TInt retVal = aProps.SoapActionL(soapAction); |
|
618 |
|
619 CSenMtomTxnState* pMtomTxnState = CSenMtomTxnState::NewL(aObserver, |
|
620 //Log(), |
|
621 &aUri, |
|
622 soapAction, |
|
623 aContent); |
|
624 |
|
625 if (aContent.SoapVersion() == ESOAP12) |
|
626 { |
|
627 aProps.RemovePropertyL(KSoapActionLocalName, MSenLayeredProperties::ESenMessageLayer); |
|
628 } |
|
629 |
|
630 CleanupStack::PushL(pMtomTxnState); |
|
631 AppendNewTxnStateL(pMtomTxnState); |
|
632 CleanupStack::Pop(); // pMtomTxnState |
|
633 |
|
634 return InvokeHttpMethodL(pMtomTxnState, aProps); |
|
635 } |
|
636 TInt CSenHttpChannelImpl::SendL(MSenResponseObserver& aObserver, |
|
637 const TDesC8& aUri, |
|
638 CSenAtomEntry& aContent, |
|
639 CSenLayeredHttpTransportProperties& aProps) |
|
640 { |
|
641 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"CSenHttpChannelImpl::SendL:"); |
|
642 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("- Endpoint URI: %S"), &aUri)); |
|
643 CSenAtomTxnState* pAtomTxnState = CSenAtomTxnState::NewL(aObserver, |
|
644 &aUri, |
|
645 aContent); |
|
646 |
|
647 CleanupStack::PushL(pAtomTxnState); |
|
648 AppendNewTxnStateL(pAtomTxnState); |
|
649 CleanupStack::Pop(); // pAtomTxnState |
|
650 |
|
651 return InvokeHttpMethodL(pAtomTxnState, aProps); |
|
652 } |
|
653 /** Invoke the http method |
|
654 This actually creates the transaction, |
|
655 sets the headers and body and then starts the transaction |
|
656 */ |
|
657 TInt CSenHttpChannelImpl::InvokeHttpMethodL(CSenTxnState* aTxnState, |
|
658 CSenLayeredHttpTransportProperties& aProps) |
|
659 { |
|
660 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"CSenHttpChannelImpl::InvokeHttpMethodL"); |
|
661 TUriParser8 uri; |
|
662 RStringF method; |
|
663 TPtrC8 deflate; |
|
664 // Set IAP preferences, if such exist in properties (and not already in effect): |
|
665 TUint32 iapId(KErrNone); |
|
666 TBool doNotPrompt(ETrue); |
|
667 |
|
668 TInt retVal = aProps.IAPDialogL( doNotPrompt ); |
|
669 if ( retVal != KErrNone ) |
|
670 { |
|
671 // by default, do not prompt (even if property does not exist!) |
|
672 // => only if property is set, and has value "FALSE", show PROMPT |
|
673 doNotPrompt = ETrue; |
|
674 } |
|
675 |
|
676 // Independent of dialog preference (property's existance), if IAP was predefined, it must be set |
|
677 if(((aProps.IapIdL(iapId)) == KErrNone)) |
|
678 { |
|
679 retVal = SetIapPrefsL(iapId, doNotPrompt, iConnection, iSockServ); |
|
680 } |
|
681 else if(((aProps.SnapIdL(iapId)) == KErrNone)) |
|
682 { |
|
683 retVal = SetSnapPrefsL(iapId, doNotPrompt, iConnection, iSockServ); |
|
684 } |
|
685 else//to better control RConnection, we have to call Start by ourselve |
|
686 { |
|
687 retVal = SetSnapPrefsL(0, EFalse, iConnection, iSockServ); |
|
688 if(retVal == KErrNotFound) |
|
689 { |
|
690 retVal = SetIapPrefsL(0, EFalse, iConnection, iSockServ); |
|
691 } |
|
692 } |
|
693 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("Set Snap/IAP prefs retVal [%d]"), retVal)); |
|
694 User::LeaveIfError(retVal); |
|
695 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"CSenHttpChannelImpl::InvokeHttpMethodL After User::Leave"); |
|
696 TInt ret=iConnection.GetIntSetting(_L("IAP\\Id"), iUsedIapId); |
|
697 // Check transport properties |
|
698 CSenLayeredHttpTransportProperties::TSenHttpMethod httpMethod; |
|
699 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("IAP %d"), iapId)); |
|
700 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("DONT PROMPT %d"), doNotPrompt)); |
|
701 TInt retValHttpMethod = aProps.HttpMethodL(httpMethod); |
|
702 |
|
703 |
|
704 /*Installing the deflate filter based on the property values */ |
|
705 /*Once installed, the filter will be alive for on session lifetime */ |
|
706 if(KErrNone == aProps.PropertyL(KWsPropertyValueHttpFilterDeflate,deflate)) |
|
707 { |
|
708 if(!iDeflateFilter) |
|
709 { |
|
710 TRAPD(err, CHttpDeflateFilter::InstallFilterL(iSess)); |
|
711 if(err == KErrNone) |
|
712 { |
|
713 iDeflateFilter = ETrue; |
|
714 TLSLOG_L(KSenHttpChannelLogChannelBase , KNormalLogLevel,"HTTPDeflateFilter installed for EKA2 build."); |
|
715 } |
|
716 else |
|
717 { |
|
718 TLSLOG_L(KSenHttpChannelLogChannelBase , KNormalLogLevel,"ERROR:HTTPDeflateFilter Not installed for EKA2 build."); |
|
719 } |
|
720 } |
|
721 } |
|
722 |
|
723 |
|
724 if(!aTxnState->HasRequestBody()) |
|
725 { |
|
726 if (retValHttpMethod) httpMethod = CSenLayeredHttpTransportProperties::ESenHttpGet; |
|
727 User::LeaveIfError( uri.Parse(aTxnState->RequestUri()) ); |
|
728 switch(httpMethod) |
|
729 { |
|
730 case CSenLayeredHttpTransportProperties::ESenHttpPost: |
|
731 { |
|
732 method = iStringPool.StringF(HTTP::EPOST, RHTTPSession::GetTable()); |
|
733 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- HTTP::EPOST"); |
|
734 } |
|
735 break; |
|
736 case CSenLayeredHttpTransportProperties::ESenHttpPut: |
|
737 { |
|
738 method = iStringPool.StringF(HTTP::EPUT, RHTTPSession::GetTable()); |
|
739 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- HTTP::EPUT"); |
|
740 } |
|
741 break; |
|
742 case CSenLayeredHttpTransportProperties::ESenHttpDelete: |
|
743 { |
|
744 method = iStringPool.StringF(HTTP::EDELETE, RHTTPSession::GetTable()); |
|
745 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- HTTP::EDELETE"); |
|
746 } |
|
747 break; |
|
748 case CSenLayeredHttpTransportProperties::ESenHttpGet: |
|
749 default: |
|
750 { |
|
751 // Default to HTTP GET, if no body has been provided |
|
752 method = iStringPool.StringF(HTTP::EGET, RHTTPSession::GetTable()); |
|
753 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- HTTP::EGET"); |
|
754 } |
|
755 } |
|
756 } |
|
757 else |
|
758 { |
|
759 // Some request "body"; or a query string for GET or DELETE was provided |
|
760 if (retValHttpMethod) httpMethod = CSenLayeredHttpTransportProperties::ESenHttpPost; |
|
761 switch(httpMethod) |
|
762 { |
|
763 case CSenLayeredHttpTransportProperties::ESenHttpGet: |
|
764 { |
|
765 method = iStringPool.StringF(HTTP::EGET, RHTTPSession::GetTable()); |
|
766 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- HTTP::EGET"); |
|
767 // The responsibility of correct query string for GET URI |
|
768 // is on the shoulders of the original invoker (public API |
|
769 // caller): |
|
770 aTxnState->TransformBodyToUriL(); |
|
771 |
|
772 // NOTE: warning from Uri16.h: |
|
773 // @warning The descriptor that is parsed by an object of this class will be referenced |
|
774 // by that object. If the original descriptor is no longer in scope there will be undefined |
|
775 // behaviour. |
|
776 User::LeaveIfError( uri.Parse(aTxnState->RequestUri()) ); |
|
777 } |
|
778 break; |
|
779 case CSenLayeredHttpTransportProperties::ESenHttpPut: |
|
780 { |
|
781 method = iStringPool.StringF(HTTP::EPUT, RHTTPSession::GetTable()); |
|
782 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- HTTP::EPUT"); |
|
783 User::LeaveIfError( uri.Parse(aTxnState->RequestUri()) ); |
|
784 } |
|
785 break; |
|
786 case CSenLayeredHttpTransportProperties::ESenHttpDelete: |
|
787 { |
|
788 method = iStringPool.StringF(HTTP::EDELETE, RHTTPSession::GetTable()); |
|
789 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- HTTP::EDELETE"); |
|
790 // The responsibility of correct query string for DELETE URI |
|
791 // argument is on the shoulders of the original invoker |
|
792 // (public API caller): |
|
793 aTxnState->TransformBodyToUriL(); |
|
794 User::LeaveIfError( uri.Parse(aTxnState->RequestUri()) ); |
|
795 } |
|
796 break; |
|
797 case CSenLayeredHttpTransportProperties::ESenHttpPost: |
|
798 default: |
|
799 { |
|
800 // default to HttpPost |
|
801 method = iStringPool.StringF(HTTP::EPOST, RHTTPSession::GetTable()); |
|
802 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- HTTP::EPOST"); |
|
803 User::LeaveIfError( uri.Parse(aTxnState->RequestUri()) ); |
|
804 } |
|
805 } |
|
806 } |
|
807 |
|
808 |
|
809 RHTTPTransaction transaction = iSess.OpenTransactionL(uri, *iTransObs, method); |
|
810 iHttpTransaction = transaction ; |
|
811 aTxnState->SetId(transaction.Id()); |
|
812 aTxnState->SetTransaction(transaction); |
|
813 aTxnState->SetSession(iSess); |
|
814 RHTTPHeaders hdr = transaction.Request().GetHeaderCollection(); |
|
815 |
|
816 // Add request headers: Accept, User-Agent, any other user defined ones |
|
817 AddRequestHeadersL(hdr, aProps); |
|
818 |
|
819 // Add Content type header and request body if available |
|
820 if(aTxnState->HasRequestBody()) |
|
821 { |
|
822 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- Adding content type header and request body"); |
|
823 |
|
824 // Set the "Content-Type" HTTP header here, and *only* here(!) |
|
825 aTxnState->SetContentTypeHeaderL(iSess, hdr); |
|
826 |
|
827 MHTTPDataSupplier* pDataSupplier = aTxnState; |
|
828 transaction.Request().SetBody(*pDataSupplier); |
|
829 } |
|
830 #ifdef _SENDEBUG |
|
831 else |
|
832 { |
|
833 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- This transaction does not carry a request body."); |
|
834 } |
|
835 #endif |
|
836 |
|
837 // Submit the transaction |
|
838 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- Submitting the transaction."); |
|
839 transaction.SubmitL(); |
|
840 return aTxnState->Id(); |
|
841 } |
|
842 |
|
843 void CSenHttpChannelImpl::NotifyMoreBodyL() |
|
844 { |
|
845 iHttpTransaction.NotifyNewRequestBodyPartL(); |
|
846 } |
|
847 |
|
848 void CSenHttpChannelImpl::SetProxyL(const TDesC8& aProxyHostBaseAddr, |
|
849 TInt aProxyPort) |
|
850 { |
|
851 TBuf8<64> port; |
|
852 port.AppendNum(aProxyPort); |
|
853 HBufC8* pProxyHostPort = HBufC8::NewLC(aProxyHostBaseAddr.Length() |
|
854 +KColon().Length() |
|
855 +port.Length()); |
|
856 |
|
857 pProxyHostPort->Des().Append( aProxyHostBaseAddr ); |
|
858 pProxyHostPort->Des().Append( KColon ); |
|
859 pProxyHostPort->Des().AppendNum( aProxyPort ); |
|
860 |
|
861 TPtrC8 proxy = pProxyHostPort->Des(); |
|
862 SetProxyL( proxy ); |
|
863 CleanupStack::PopAndDestroy(pProxyHostPort); |
|
864 } |
|
865 |
|
866 void CSenHttpChannelImpl::SetProxyL(const TDesC8& aProxyAddrStr) |
|
867 { |
|
868 if(iProxyHostPort && iProxyHostPort->Compare(aProxyAddrStr)==0) |
|
869 { |
|
870 // nothing to do, proxy address is already in use |
|
871 return; |
|
872 } |
|
873 |
|
874 delete iProxyHostPort; |
|
875 iProxyHostPort = NULL; |
|
876 |
|
877 iProxyHostPort = aProxyAddrStr.AllocL(); |
|
878 |
|
879 RStringF proxyAddr = iSess.StringPool().OpenFStringL(*iProxyHostPort); |
|
880 |
|
881 CleanupClosePushL(proxyAddr); |
|
882 |
|
883 // Set the proxy here... |
|
884 RHTTPConnectionInfo connInfo = iSess.ConnectionInfo(); |
|
885 THTTPHdrVal proxyUsage( |
|
886 iSess.StringPool().StringF(HTTP::EUseProxy, RHTTPSession::GetTable())); |
|
887 connInfo.SetPropertyL( |
|
888 iSess.StringPool().StringF(HTTP::EProxyUsage, RHTTPSession::GetTable()), |
|
889 proxyUsage); |
|
890 connInfo.SetPropertyL( |
|
891 iSess.StringPool().StringF( |
|
892 HTTP::EProxyAddress, RHTTPSession::GetTable()), proxyAddr); |
|
893 |
|
894 CleanupStack::PopAndDestroy(); // proxyAddr |
|
895 } |
|
896 |
|
897 void CSenHttpChannelImpl::SetHttpVersionL(TInt aVersion) |
|
898 { |
|
899 HTTP::TStrings httpVersion = HTTP::EHttp11; |
|
900 if(0 == aVersion) |
|
901 { |
|
902 httpVersion = HTTP::EHttp10; |
|
903 } |
|
904 |
|
905 RHTTPConnectionInfo connInfo = iSess.ConnectionInfo(); |
|
906 RStringPool p=iSess.StringPool(); |
|
907 connInfo.SetPropertyL(p.StringF( |
|
908 HTTP::EHTTPVersion,RHTTPSession::GetTable()), |
|
909 THTTPHdrVal( |
|
910 p.StringF(httpVersion,RHTTPSession::GetTable()))); |
|
911 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KNormalLogLevel, _L8("Http version is set to HTTP 1.%d"), aVersion)); |
|
912 } |
|
913 |
|
914 void CSenHttpChannelImpl::SetProxyUsageL(TBool aProxyUsage) |
|
915 { |
|
916 RHTTPConnectionInfo connInfo = iSess.ConnectionInfo(); |
|
917 RStringPool strPool=iSess.StringPool(); |
|
918 if ( aProxyUsage ) |
|
919 { |
|
920 connInfo.SetPropertyL |
|
921 ( |
|
922 strPool.StringF( HTTP::EProxyUsage, RHTTPSession::GetTable() ), |
|
923 THTTPHdrVal( strPool.StringF(HTTP::EUseProxy, RHTTPSession::GetTable() ) ) |
|
924 ); |
|
925 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("Http Proxy usage is set to TRUE"))); |
|
926 } |
|
927 else |
|
928 { |
|
929 connInfo.SetPropertyL |
|
930 ( |
|
931 strPool.StringF( HTTP::EProxyUsage, RHTTPSession::GetTable() ), |
|
932 THTTPHdrVal( strPool.StringF(HTTP::EDoNotUseProxy, RHTTPSession::GetTable() ) ) |
|
933 ); |
|
934 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("Http Proxy usage is set to FALSE"))); |
|
935 |
|
936 } |
|
937 } |
|
938 |
|
939 void CSenHttpChannelImpl::SetSecureDialogL(TBool aSecureDialog) |
|
940 { |
|
941 RHTTPConnectionInfo connInfo = iSess.ConnectionInfo(); |
|
942 RStringPool strPool=iSess.StringPool(); |
|
943 if ( aSecureDialog ) |
|
944 { |
|
945 connInfo.SetPropertyL |
|
946 ( |
|
947 strPool.StringF( HTTP::ESecureDialog, RHTTPSession::GetTable() ), |
|
948 THTTPHdrVal( strPool.StringF(HTTP::EDialogPrompt, RHTTPSession::GetTable() ) ) |
|
949 ); |
|
950 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("Http Secure dialog prompt is set to TRUE"))); |
|
951 } |
|
952 else |
|
953 { |
|
954 connInfo.SetPropertyL |
|
955 ( |
|
956 strPool.StringF( HTTP::ESecureDialog, RHTTPSession::GetTable() ), |
|
957 THTTPHdrVal( strPool.StringF(HTTP::EDialogNoPrompt, RHTTPSession::GetTable() ) ) |
|
958 ); |
|
959 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("Http Secure dialog prompt is set to FALSE"))); |
|
960 |
|
961 } |
|
962 } |
|
963 |
|
964 // ---------------------------------------------------------------------------- |
|
965 // CSenHttpChannelImpl::AddRequestHeadersL |
|
966 // Adds headers to the request. |
|
967 // ---------------------------------------------------------------------------- |
|
968 void CSenHttpChannelImpl::AddRequestHeadersL(RHTTPHeaders& aHeaders, |
|
969 CSenLayeredHttpTransportProperties& aProps) |
|
970 { |
|
971 TLSLOG(KSenHttpChannelLogChannelBase , KMinLogLevel,(_L("CSenHttpChannelImpl::AddRequestHeadersL"))); |
|
972 |
|
973 |
|
974 //TPtrC8 useragent; |
|
975 TInt retVal;// = aProps.UserAgentL(useragent); |
|
976 |
|
977 // It is MANDATORY, that User-Agent header exists: |
|
978 // if ( useragent.Length()== 0 ) |
|
979 // { |
|
980 // //iProperties->SetPropertyL(KUserAgentLocalName, KSenHttpChannelUserAgentHeaderDefault, KHttpHeaderType); |
|
981 // useragent.Set( KSenHttpChannelUserAgentHeaderDefault ); |
|
982 // } |
|
983 |
|
984 // Fetch the accepted content types: |
|
985 MSenProperty* acceptHeaders = NULL; |
|
986 retVal = aProps.AcceptL(acceptHeaders); |
|
987 RPointerArray<TPtrC8> tokens; |
|
988 CleanupClosePushL(tokens); |
|
989 |
|
990 if(retVal == KErrNone) |
|
991 { |
|
992 if(acceptHeaders) |
|
993 { |
|
994 TInt retVal = acceptHeaders->ValueTokensL(KSenHttpAcceptHeaderDelimiter, tokens); |
|
995 // Sanity check |
|
996 if(retVal == KErrNone && tokens.Count()==0) |
|
997 { |
|
998 retVal = KErrNotFound; // should not happen |
|
999 } |
|
1000 } |
|
1001 else |
|
1002 { |
|
1003 retVal = KErrNotFound; // should not happen |
|
1004 } |
|
1005 } |
|
1006 |
|
1007 // It is MANDATORY, that at least one Accept header TOKEN exists: |
|
1008 if ( tokens.Count()==0 ) |
|
1009 { |
|
1010 TPtrC8* pDefaultToken = new (ELeave) TPtrC8( KSenHttpChannelAcceptHeaderDefault ); |
|
1011 TInt error = tokens.Append( pDefaultToken ); |
|
1012 if ( error ) |
|
1013 { |
|
1014 delete pDefaultToken; |
|
1015 } |
|
1016 } |
|
1017 // Http headers |
|
1018 TInt headerCount(0); |
|
1019 RPointerArray<MSenProperty> headersArray; |
|
1020 retVal = aProps.HttpHeadersL(headersArray); |
|
1021 if ( retVal == KErrNone ) |
|
1022 { |
|
1023 CleanupClosePushL(headersArray); |
|
1024 headerCount = headersArray.Count(); |
|
1025 for(TInt i=0; i<headerCount; i++) |
|
1026 { |
|
1027 MSenProperty* property = headersArray[i]; |
|
1028 if(property) |
|
1029 { |
|
1030 TPtrC8 name = property->Name(); |
|
1031 |
|
1032 // Check if header name is "Content-Type" |
|
1033 if(!name.Compare(KContentTypeLocalName) || |
|
1034 !name.Compare(KAcceptLocalName)) |
|
1035 { |
|
1036 // Skip Content-Type header(s) in here: |
|
1037 // - otherwise HTTP GET might get confused |
|
1038 |
|
1039 // NOTE(!): Content-Type header is added separately |
|
1040 // through CSenTxnState -object: |
|
1041 // @InvokeHttpMethodL() |
|
1042 continue; |
|
1043 } |
|
1044 |
|
1045 TPtrC8 value = property->Value(); |
|
1046 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("- Adding HTTP HEADER, name: (%S), value: (%S)"), |
|
1047 &name, &value)); |
|
1048 |
|
1049 // Open stringpool strings |
|
1050 RStringF headerName = iStringPool.OpenFStringL(name); |
|
1051 CleanupClosePushL(headerName); |
|
1052 RStringF headerValue = iStringPool.OpenFStringL(value); |
|
1053 CleanupClosePushL(headerValue); |
|
1054 // Create header name field |
|
1055 THTTPHdrVal headerFieldVal; |
|
1056 headerFieldVal.SetStrF(headerValue); |
|
1057 // Check if the header field value already exists |
|
1058 TBool fieldValueExists = EFalse; |
|
1059 TInt fieldCount = aHeaders.FieldPartsL(headerName); |
|
1060 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("Header < %S > field count: %d"), &name, |
|
1061 fieldCount)); |
|
1062 |
|
1063 for(TInt j=0; j<fieldCount; j++) |
|
1064 { |
|
1065 THTTPHdrVal hVal; |
|
1066 TInt retCode = aHeaders.GetField(headerName, j, hVal); |
|
1067 if(KErrNotFound != retCode) |
|
1068 { |
|
1069 if(hVal == headerFieldVal) |
|
1070 { |
|
1071 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("Header < %S: %S > already exists"), |
|
1072 &name, &value)); |
|
1073 |
|
1074 fieldValueExists = ETrue; |
|
1075 } |
|
1076 } |
|
1077 } |
|
1078 |
|
1079 // Add header field |
|
1080 if(!fieldValueExists) |
|
1081 { |
|
1082 aHeaders.SetFieldL(headerName, headerFieldVal); |
|
1083 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("Header < %S: %S > added"), |
|
1084 &name, &value)); |
|
1085 } |
|
1086 |
|
1087 // Close stringpool strings |
|
1088 CleanupStack::PopAndDestroy(2); // headerValue, headerName |
|
1089 } |
|
1090 } |
|
1091 headersArray.Reset(); |
|
1092 CleanupStack::Pop(); // headersArray |
|
1093 } |
|
1094 else |
|
1095 { |
|
1096 // No HTTP headers were found(!) |
|
1097 User::Leave( retVal ); |
|
1098 } |
|
1099 |
|
1100 for (TInt k = 0; k < tokens.Count(); k++) |
|
1101 { |
|
1102 TPtrC8 token = *tokens[k]; // accept header value |
|
1103 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("- Adding token to Accept header (%S)"), tokens[k])); |
|
1104 |
|
1105 //const TDesC8& acceptHeaderValueStr |
|
1106 // = iAcceptedContentTypes->MdcaPoint(k); |
|
1107 |
|
1108 // Open stringpool string |
|
1109 RStringF acceptHeaderValue |
|
1110 = iStringPool.OpenFStringL(token); |
|
1111 |
|
1112 CleanupClosePushL(acceptHeaderValue); |
|
1113 |
|
1114 // Create header name field |
|
1115 THTTPHdrVal headerFieldVal; |
|
1116 headerFieldVal.SetStrF(acceptHeaderValue); |
|
1117 |
|
1118 // Check if the header field value already exists |
|
1119 TBool fieldValueExists = EFalse; |
|
1120 |
|
1121 TInt fieldCount = aHeaders.FieldPartsL( |
|
1122 iStringPool.StringF(HTTP::EAccept, RHTTPSession::GetTable())); |
|
1123 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KNormalLogLevel, _L8("Accept header field count: %d"), fieldCount)); |
|
1124 |
|
1125 |
|
1126 for(TInt j = 0; j < fieldCount; j++) |
|
1127 { |
|
1128 THTTPHdrVal hVal; |
|
1129 TInt retCode = aHeaders.GetField( |
|
1130 iStringPool.StringF(HTTP::EAccept, |
|
1131 RHTTPSession::GetTable()), |
|
1132 j, |
|
1133 hVal); |
|
1134 |
|
1135 if(KErrNotFound != retCode) |
|
1136 { |
|
1137 #ifdef _SENDEBUG |
|
1138 const TDesC8& hValStr = hVal.StrF().DesC(); |
|
1139 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("Accept: %S"), |
|
1140 &hValStr)); |
|
1141 #endif // _SENDEBUG |
|
1142 if(hVal == headerFieldVal) |
|
1143 { |
|
1144 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("Header < Accept: %S > already exists"), &token)); |
|
1145 fieldValueExists = ETrue; |
|
1146 } |
|
1147 } |
|
1148 } |
|
1149 |
|
1150 // Add header field |
|
1151 if(!fieldValueExists) |
|
1152 { |
|
1153 aHeaders.SetFieldL( |
|
1154 iStringPool.StringF(HTTP::EAccept, |
|
1155 RHTTPSession::GetTable()), |
|
1156 headerFieldVal); |
|
1157 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("Header < Accept: %S > added"), &token)); |
|
1158 |
|
1159 } |
|
1160 |
|
1161 // Close stringpool string |
|
1162 CleanupStack::PopAndDestroy(); // acceptHeaderValue |
|
1163 } |
|
1164 tokens.ResetAndDestroy(); // TPtrC8 is allocated with "new" keyword and thus owned by this array, eventhough |
|
1165 // the actual descriptors inside TPtrC8 tokens are NOT owned, of course (NORMAL). |
|
1166 CleanupStack::PopAndDestroy(); // token array |
|
1167 } |
|
1168 |
|
1169 /** Called when a authenticated page is requested |
|
1170 Asks the user for a username and password that would be appropriate for the |
|
1171 url that was supplied. |
|
1172 */ |
|
1173 TBool CSenHttpChannelImpl::GetCredentialsL(const TUriC8& aURI, |
|
1174 RString aRealm, |
|
1175 RStringF /*aAuthenticationType*/, |
|
1176 RString& aUsername, |
|
1177 RString& aPassword) |
|
1178 |
|
1179 { |
|
1180 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("GetCredentialsL(), for URL (%S), realm (%S)"), |
|
1181 &aURI.UriDes(), &aRealm.DesC())); |
|
1182 |
|
1183 if (iBasicConnectionTries > 2) |
|
1184 { |
|
1185 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"GetCredentialsL() max number of tries with auth-dialog reached (3)"); |
|
1186 // In the next attempt start with a fresh identityprovider |
|
1187 iSessionAuthentication = NULL; |
|
1188 iPasswordFromUser = EFalse; |
|
1189 iBasicConnectionTries = 0; |
|
1190 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"GetCredentialsL() returning EFalse"); |
|
1191 return EFalse; // Invalid login attempts have reached the defined |
|
1192 // maximum, abort this request |
|
1193 } |
|
1194 |
|
1195 if (!iSessionAuthentication) |
|
1196 { |
|
1197 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"GetCredentialsL() reading auth-pair from database (senidentites.xml)"); |
|
1198 iSessionAuthentication = iManager.IdentityProviderL(aURI.UriDes()); |
|
1199 if(!iSessionAuthentication) |
|
1200 { |
|
1201 // create and register new IDP |
|
1202 iSessionAuthentication = CSenIdentityProvider::NewL(aURI.UriDes(), |
|
1203 KNullDesC8); |
|
1204 iSessionAuthentication->SetFrameworkIdL(KNullDesC8); |
|
1205 TInt retVal = iManager.RegisterIdentityProviderL(iSessionAuthentication); |
|
1206 if(retVal!=KErrNone) |
|
1207 { |
|
1208 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("GetCredentials: Register IDP failed! Error code: (%d)"), |
|
1209 retVal)); |
|
1210 iSessionAuthentication = NULL; |
|
1211 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"GetCredentialsL() returning EFalse"); |
|
1212 return EFalse; // decision: we could not save info into database, abort |
|
1213 } |
|
1214 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"New IDP registeration OK. Proceeding."); |
|
1215 } |
|
1216 // we have credentials |
|
1217 TRAPD(err, aUsername = |
|
1218 aRealm.Pool().OpenStringL(iSessionAuthentication->AuthzID())); |
|
1219 TRAP(err, aPassword = |
|
1220 aRealm.Pool().OpenStringL(iSessionAuthentication->Password())); |
|
1221 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"GetCredentialsL() returning ETrue"); |
|
1222 return ETrue; |
|
1223 } |
|
1224 else |
|
1225 { |
|
1226 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"GetCredentialsL() prompting auth-info from user via dialog."); |
|
1227 // Remove the old password before asking the new one. |
|
1228 CSenElement& element = iSessionAuthentication->AsElement(); |
|
1229 delete element.RemoveElement(KSenIdpPasswordLocalname); |
|
1230 |
|
1231 TPckgBuf<TSenAuthentication> authInfo; |
|
1232 iManager.AuthenticationForL(*iSessionAuthentication, authInfo); |
|
1233 iPasswordFromUser = ETrue; |
|
1234 |
|
1235 TRAPD(err, aUsername = |
|
1236 aRealm.Pool().OpenStringL(authInfo().iUsername)); |
|
1237 TRAP(err, aPassword = |
|
1238 aRealm.Pool().OpenStringL(authInfo().iPassword)); |
|
1239 iBasicConnectionTries++; |
|
1240 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"GetCredentialsL() returning ETrue"); |
|
1241 return ETrue; |
|
1242 } |
|
1243 } |
|
1244 |
|
1245 // This is a debug logging method: |
|
1246 void CSenHttpChannelImpl::ListFilters() |
|
1247 { |
|
1248 #ifdef _SENDEBUG |
|
1249 TLSLOG_L(KSenHttpChannelLogChannelBase , KMaxLogLevel,"List HTTP filters started."); |
|
1250 TLSLOG(KSenHttpChannelLogChannelBase , KMaxLogLevel,(_L( |
|
1251 " Name | Pos'n | Event | Header | Status | Handle ") |
|
1252 )); |
|
1253 TLSLOG(KSenHttpChannelLogChannelBase , KMaxLogLevel,(_L( |
|
1254 "-----------------+-------+--------+------------------+--------+--------") |
|
1255 )); |
|
1256 |
|
1257 RHTTPFilterCollection filtColl = iSess.FilterCollection(); |
|
1258 THTTPFilterIterator iter = filtColl.Query(); |
|
1259 |
|
1260 THTTPFilterRegistration regInfo; |
|
1261 iter.First(); |
|
1262 TBuf<KMaxFilterNameLen> earlierName; |
|
1263 while (!iter.AtEnd()) |
|
1264 { |
|
1265 // Get next filter registration info |
|
1266 regInfo = iter(); |
|
1267 |
|
1268 TBuf<KMaxFilterNameLen> name; |
|
1269 name.Copy(iSess.StringPool().StringF(regInfo.iName).DesC().Left( |
|
1270 KMaxFilterNameLen)); |
|
1271 TBuf<KMaxHeaderNameLen> header; |
|
1272 header.Copy(iSess.StringPool().StringF(regInfo.iHeader).DesC().Left( |
|
1273 KMaxHeaderNameLen)); |
|
1274 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMaxLogLevel, _L8("%16S | %4d | %4d | %16S | %3d | %2d"), |
|
1275 &name, regInfo.iPosition, regInfo.iEvent.iStatus, &header, |
|
1276 regInfo.iStatus, regInfo.iHandle)); |
|
1277 |
|
1278 earlierName.Format(name); |
|
1279 ++iter; |
|
1280 } |
|
1281 TLSLOG_L(KSenHttpChannelLogChannelBase , KMaxLogLevel,"List HTTP filters done."); |
|
1282 #endif |
|
1283 } |
|
1284 |
|
1285 void CSenHttpChannelImpl::HandleResponseHeadersL(RHTTPTransaction aTransaction) |
|
1286 { |
|
1287 TInt txnId = aTransaction.Id(); |
|
1288 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("CSenHttpChannelImpl::HandleResponseHeadersL( %d )"), |
|
1289 txnId)); |
|
1290 |
|
1291 RHTTPResponse resp = aTransaction.Response(); |
|
1292 TInt status = resp.StatusCode(); |
|
1293 #ifdef _SENDEBUG |
|
1294 RStringF statusStr = resp.StatusText(); |
|
1295 const TDesC8& statusStrDesC = statusStr.DesC(); |
|
1296 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("Response status: %d ( %S )"), status, &statusStrDesC)); |
|
1297 #endif // _SENDEBUG |
|
1298 CSenTxnState* pTxnState = FindTxnState(txnId); |
|
1299 |
|
1300 __ASSERT_ALWAYS(pTxnState != NULL, User::Panic(KTxnStateNullPanicText, CSenHttpChannel::ETxnStateNull)); |
|
1301 |
|
1302 if (status == 401) // basic authentication needed |
|
1303 { |
|
1304 CSenHttpTransportProperties* tp = CSenHttpTransportProperties::NewLC(); |
|
1305 RHTTPHeaders responseHeaders = aTransaction.Response().GetHeaderCollection(); |
|
1306 THTTPHdrFieldIter fields = responseHeaders.Fields(); |
|
1307 while (!fields.AtEnd()) |
|
1308 { |
|
1309 RStringTokenF fieldName = fields(); |
|
1310 RStringF fieldNameStr = iStringPool.StringF(fieldName); |
|
1311 THTTPHdrVal fieldVal; |
|
1312 if (responseHeaders.GetField(fieldNameStr,0,fieldVal) == KErrNone) |
|
1313 { |
|
1314 TPtrC8 ptr(KNullDesC8); |
|
1315 responseHeaders.GetRawField(fieldNameStr, ptr); |
|
1316 TPtrC8 ptr2(fieldNameStr.DesC()); |
|
1317 if (fieldVal.Type() == THTTPHdrVal::KDateVal) |
|
1318 { |
|
1319 TDateTime date = fieldVal.DateTime(); |
|
1320 RStringF dateS = iStringPool.StringF(HTTP::EDate, RHTTPSession::GetTable()); |
|
1321 TTimeIntervalMinutes interval; |
|
1322 TTime begin(0); |
|
1323 TTime time(date); |
|
1324 time.MinutesFrom(begin, interval); |
|
1325 tp->SetIntPropertyL(dateS.DesC(), interval.Int()); |
|
1326 pTxnState->SetTP(tp);//ownership transfered |
|
1327 pTxnState->HttpChannelPropertiesL().SetIntPropertyL(dateS.DesC(), interval.Int()); |
|
1328 } |
|
1329 } |
|
1330 ++fields; |
|
1331 } |
|
1332 CleanupStack::Pop(tp); |
|
1333 return; |
|
1334 } |
|
1335 |
|
1336 else if (status == 200) |
|
1337 { |
|
1338 RHTTPHeaders responseHeaders = aTransaction.Response().GetHeaderCollection(); |
|
1339 |
|
1340 THTTPHdrVal fieldVal; |
|
1341 TPtrC8 fieldValPtr; |
|
1342 THTTPHdrVal paramVal; |
|
1343 |
|
1344 // get the Content-Type string |
|
1345 RStringF content = iStringPool.StringF(HTTP::EContentType, |
|
1346 RHTTPSession::GetTable()); |
|
1347 |
|
1348 if (responseHeaders.GetField(content,0,fieldVal) == KErrNone) |
|
1349 { |
|
1350 // get the field value |
|
1351 switch (fieldVal.Type()) |
|
1352 { |
|
1353 case THTTPHdrVal::KStrFVal: |
|
1354 { |
|
1355 fieldValPtr.Set(iStringPool.StringF(fieldVal.StrF()).DesC()); |
|
1356 } |
|
1357 break; |
|
1358 case THTTPHdrVal::KStrVal: |
|
1359 { |
|
1360 fieldValPtr.Set(iStringPool.String(fieldVal.Str()).DesC()); |
|
1361 } |
|
1362 break; |
|
1363 default: |
|
1364 { |
|
1365 User::Panic(KUnrecognisedValueTypeOfContentTypePanicText, |
|
1366 EContentTypeUnrecognisedValueType); |
|
1367 } |
|
1368 } |
|
1369 _LIT8(KMultipartRelated,"Multipart/Related"); //CodeScannerWarning |
|
1370 _LIT8(KBoundry,"boundary"); |
|
1371 _LIT8(KType,"type"); |
|
1372 _LIT8(KStart,"start"); |
|
1373 _LIT8(KStartInfo,"start-info"); |
|
1374 _LIT8(KAction,"action"); |
|
1375 _LIT8(KApplication,"application/xop+xml"); |
|
1376 if (fieldValPtr == KMultipartRelated) |
|
1377 { |
|
1378 //SenMultiPartUtils::TMultiPartContentType MultiPartContentType; |
|
1379 iMultiPartContentType.fieldValue.Set(fieldValPtr); |
|
1380 |
|
1381 // get the param values |
|
1382 TPtrC8 paramName(KBoundry); |
|
1383 if(KErrNone == ContentTypeParamValueL(responseHeaders, content, paramName, iMultiPartContentType)) |
|
1384 { |
|
1385 paramName.Set(KType); |
|
1386 if (KErrNone == ContentTypeParamValueL(responseHeaders, content, paramName, iMultiPartContentType)) |
|
1387 { |
|
1388 paramName.Set(KStart); |
|
1389 if (KErrNone == ContentTypeParamValueL(responseHeaders, content, paramName, iMultiPartContentType)) |
|
1390 { |
|
1391 paramName.Set(KStartInfo); |
|
1392 if (KErrNone == ContentTypeParamValueL(responseHeaders, content, paramName, iMultiPartContentType)) |
|
1393 { |
|
1394 paramName.Set(KAction); |
|
1395 if (KErrSenNoHttpContentType == ContentTypeParamValueL(responseHeaders, content, paramName, iMultiPartContentType)) |
|
1396 { |
|
1397 SenMultiPartUtils::TMultiPartContentTypeParam contentTypeParam = {_L8("action"), _L8("")}; |
|
1398 iMultiPartContentType.params.Append(contentTypeParam); |
|
1399 } |
|
1400 TUint i(0); |
|
1401 while (iMultiPartContentType.params[i].paramName != KType) |
|
1402 { |
|
1403 ++i; |
|
1404 } |
|
1405 if (iMultiPartContentType.params[i].paramValue == KApplication) |
|
1406 { |
|
1407 iXopResponse = ETrue; |
|
1408 content.Close(); |
|
1409 return; |
|
1410 } |
|
1411 } |
|
1412 } |
|
1413 } |
|
1414 } |
|
1415 } |
|
1416 else |
|
1417 { |
|
1418 iContentType.Set(fieldValPtr); |
|
1419 content.Close(); |
|
1420 return; |
|
1421 } |
|
1422 } |
|
1423 iHasHttpContentType = EFalse; |
|
1424 content.Close(); |
|
1425 } |
|
1426 } |
|
1427 |
|
1428 TInt CSenHttpChannelImpl::ContentTypeParamValueL(const RHTTPHeaders& aResponseHeaders, |
|
1429 const RStringF& aContent, |
|
1430 const TPtrC8& aParamName, |
|
1431 SenMultiPartUtils::TMultiPartContentType& aMultiPartContentType) |
|
1432 { |
|
1433 RStringF paramNameStr = iStringPool.OpenFStringL(aParamName); |
|
1434 |
|
1435 THTTPHdrVal paramVal; |
|
1436 TPtrC8 paramValPtr; |
|
1437 if (aResponseHeaders.GetParam(aContent,paramNameStr,paramVal) == KErrNone) |
|
1438 { |
|
1439 switch (paramVal.Type()) |
|
1440 { |
|
1441 case THTTPHdrVal::KStrFVal: |
|
1442 { |
|
1443 paramValPtr.Set(iStringPool.StringF(paramVal.StrF()).DesC()); |
|
1444 } |
|
1445 break; |
|
1446 case THTTPHdrVal::KStrVal: |
|
1447 { |
|
1448 paramValPtr.Set(iStringPool.String(paramVal.Str()).DesC()); |
|
1449 } |
|
1450 break; |
|
1451 default: |
|
1452 User::Panic(KUnrecognisedValueTypeOfContentTypePanicText, |
|
1453 EContentTypeUnrecognisedValueType); |
|
1454 break; |
|
1455 } |
|
1456 |
|
1457 SenMultiPartUtils::TMultiPartContentTypeParam contentTypeParam = {_L8(""), _L8("")}; |
|
1458 contentTypeParam.paramName.Set(aParamName); |
|
1459 contentTypeParam.paramValue.Set(paramValPtr); |
|
1460 aMultiPartContentType.params.Append(contentTypeParam); |
|
1461 paramNameStr.Close(); |
|
1462 return KErrNone; |
|
1463 } |
|
1464 else |
|
1465 { |
|
1466 paramNameStr.Close(); |
|
1467 return KErrSenNoHttpContentType; |
|
1468 } |
|
1469 } |
|
1470 |
|
1471 void CSenHttpChannelImpl::HandleResponseBodyDataL(RHTTPTransaction aTransaction) |
|
1472 { |
|
1473 TInt txnId = aTransaction.Id(); |
|
1474 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("CSenHttpChannelImpl::HandleResponseBodyDataL( %d )"), txnId)); |
|
1475 |
|
1476 CSenTxnState* pTxnState = FindTxnState(txnId); |
|
1477 __ASSERT_ALWAYS(pTxnState != NULL, |
|
1478 User::Panic(KTxnStateNullPanicText, |
|
1479 CSenHttpChannel::ETxnStateNull)); |
|
1480 |
|
1481 // Get the body data supplier |
|
1482 MHTTPDataSupplier* pRespBody = aTransaction.Response().Body(); |
|
1483 |
|
1484 if(pRespBody) |
|
1485 { |
|
1486 TPtrC8 dataChunk; |
|
1487 #ifdef _SENDEBUG |
|
1488 TBool isLast = pRespBody->GetNextDataPart(dataChunk); |
|
1489 if (isLast) |
|
1490 TLSLOG(KSenHttpChannelLogChannelBase , KMinLogLevel,(_L("Got last data chunk."))); |
|
1491 #else |
|
1492 pRespBody->GetNextDataPart(dataChunk); |
|
1493 #endif // _SENDEBUG |
|
1494 |
|
1495 if (!iXopResponse) |
|
1496 { |
|
1497 pTxnState->CollectResponseBodyL(dataChunk); |
|
1498 } |
|
1499 else |
|
1500 { |
|
1501 ((CSenMtomTxnState*)pTxnState)->ParseMultiPartResponseL(dataChunk); |
|
1502 } |
|
1503 |
|
1504 |
|
1505 // Done with that bit of body data |
|
1506 pRespBody->ReleaseData(); |
|
1507 } |
|
1508 else |
|
1509 { |
|
1510 //pTxnState->ResponseError(-20000); |
|
1511 pTxnState->ResponseErrorL(KErrSenNoHttpResponseBody); //SenServiceConnection.h // was -20000 |
|
1512 DeleteTxnState(txnId); |
|
1513 aTransaction.Close(); |
|
1514 } |
|
1515 } |
|
1516 |
|
1517 void CSenHttpChannelImpl::HandleResponseL(RHTTPTransaction aTransaction) |
|
1518 { |
|
1519 TInt txnId = aTransaction.Id(); |
|
1520 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("CSenHttpChannelImpl::HandleResponseL( %d )"), txnId)); |
|
1521 CSenTxnState* pTxnState = FindTxnState(txnId); |
|
1522 __ASSERT_ALWAYS(pTxnState != NULL, |
|
1523 User::Panic(KTxnStateNullPanicText, |
|
1524 CSenHttpChannel::ETxnStateNull)); |
|
1525 |
|
1526 // Propagate http status codes |
|
1527 RHTTPResponse resp = aTransaction.Response(); |
|
1528 TInt status = resp.StatusCode(); |
|
1529 pTxnState->StateChanged(status); |
|
1530 |
|
1531 if (iHasHttpContentType) |
|
1532 { |
|
1533 if (!iXopResponse) |
|
1534 { |
|
1535 pTxnState->ResponseReceivedL(iContentType); |
|
1536 } |
|
1537 else |
|
1538 { |
|
1539 ((CSenMtomTxnState*)pTxnState)->ResponseReceivedL(iMultiPartContentType); |
|
1540 } |
|
1541 } |
|
1542 else |
|
1543 { |
|
1544 pTxnState->ResponseErrorL(KErrSenNoHttpContentType); // was: -20001 |
|
1545 } |
|
1546 |
|
1547 DeleteTxnState(txnId); |
|
1548 aTransaction.Close(); |
|
1549 } |
|
1550 |
|
1551 void CSenHttpChannelImpl::HandleRunErrorL(RHTTPTransaction aTransaction, |
|
1552 TInt aError) |
|
1553 { |
|
1554 TInt txnId = aTransaction.Id(); |
|
1555 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("CSenHttpChannelImpl::HandleRunErrorL( %d ): %d"),txnId, aError)); |
|
1556 CSenTxnState* pTxnState = FindTxnState(txnId); |
|
1557 __ASSERT_ALWAYS(pTxnState != NULL, |
|
1558 User::Panic(KTxnStateNullPanicText, |
|
1559 CSenHttpChannel::ETxnStateNull)); |
|
1560 |
|
1561 pTxnState->ResponseErrorL(aError); |
|
1562 DeleteTxnState(txnId); |
|
1563 aTransaction.Close(); |
|
1564 } |
|
1565 |
|
1566 void CSenHttpChannelImpl::HandleRedirectRequiresConfirmationL( |
|
1567 RHTTPTransaction aTransaction) |
|
1568 { |
|
1569 TInt txnId = aTransaction.Id(); |
|
1570 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("CSenHttpChannelImpl::HandleRedirectRequiresConfirmationL( %d )"), |
|
1571 txnId)); |
|
1572 CSenTxnState* pTxnState = FindTxnState(txnId); |
|
1573 __ASSERT_ALWAYS(pTxnState != NULL, |
|
1574 User::Panic(KTxnStateNullPanicText, |
|
1575 CSenHttpChannel::ETxnStateNull)); |
|
1576 pTxnState->ResponseErrorL(KErrSenHttpRedirectRequiresConfirmation); // was: -20002 |
|
1577 DeleteTxnState(txnId); |
|
1578 aTransaction.Close(); |
|
1579 } |
|
1580 /* |
|
1581 RFileLogger* CSenHttpChannelImpl::Log() const |
|
1582 { |
|
1583 return (RFileLogger*) &iLog; |
|
1584 } |
|
1585 */ |
|
1586 // This is a debug logging method |
|
1587 #ifdef _SENDEBUG |
|
1588 void CSenHttpChannelImpl::DumpRespHeadersL(RHTTPTransaction& aTrans) |
|
1589 { |
|
1590 TLSLOG(KSenHttpChannelLogChannelBase , KMinLogLevel,(_L("CSenHttpChannelImpl::DumpRespHeadersL"))); |
|
1591 RHTTPResponse resp = aTrans.Response(); |
|
1592 RHTTPHeaders hdr = resp.GetHeaderCollection(); |
|
1593 THTTPHdrFieldIter it = hdr.Fields(); |
|
1594 |
|
1595 TBuf<KMaxHeaderNameLen> fieldName16; |
|
1596 TBuf<KMaxHeaderValueLen> fieldVal16; |
|
1597 TBuf<KMaxHeaderNameLen> paramName16; |
|
1598 TBuf<KMaxHeaderValueLen> paramVal16; |
|
1599 |
|
1600 while (!it.AtEnd()) |
|
1601 { |
|
1602 RStringTokenF fieldName = it(); |
|
1603 RStringF fieldNameStr = iStringPool.StringF(fieldName); |
|
1604 THTTPHdrVal fieldVal; |
|
1605 THTTPHdrVal paramVal; |
|
1606 if (hdr.GetField(fieldNameStr,0,fieldVal) == KErrNone) |
|
1607 { |
|
1608 const TDesC8& fieldNameDesC = fieldNameStr.DesC(); |
|
1609 fieldName16.Copy(fieldNameDesC.Left(KMaxHeaderNameLen)); |
|
1610 switch (fieldVal.Type()) |
|
1611 { |
|
1612 case THTTPHdrVal::KTIntVal: |
|
1613 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("%S: %d"), &fieldName16, fieldVal.Int())); |
|
1614 break; |
|
1615 case THTTPHdrVal::KStrFVal: |
|
1616 { |
|
1617 RStringF fieldValStr = iStringPool.StringF(fieldVal.StrF()); |
|
1618 const TDesC8& fieldValDesC = fieldValStr.DesC(); |
|
1619 fieldVal16.Copy(fieldValDesC.Left(KMaxHeaderValueLen)); |
|
1620 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("%S: %S"), &fieldName16, &fieldVal16)); |
|
1621 } |
|
1622 break; |
|
1623 case THTTPHdrVal::KStrVal: |
|
1624 { |
|
1625 RString fieldValStr = iStringPool.String(fieldVal.Str()); |
|
1626 const TDesC8& fieldValDesC = fieldValStr.DesC(); |
|
1627 fieldVal16.Copy(fieldValDesC.Left(KMaxHeaderValueLen)); |
|
1628 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("%S: %S"), &fieldName16, &fieldVal16)); |
|
1629 } |
|
1630 break; |
|
1631 case THTTPHdrVal::KDateVal: |
|
1632 { |
|
1633 TDateTime date = fieldVal.DateTime(); |
|
1634 TBuf<40> dateTimeString; |
|
1635 TTime t(date); |
|
1636 t.FormatL(dateTimeString,KDateFormat); |
|
1637 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("%S: %S"), &fieldName16, &dateTimeString)); |
|
1638 |
|
1639 } |
|
1640 break; |
|
1641 default: |
|
1642 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("%S: <unrecognised value type>"), &fieldName16)); |
|
1643 break; |
|
1644 } |
|
1645 |
|
1646 RStringF paramNameStr = iStringPool.OpenFStringL(_L8("type")); |
|
1647 const TDesC8& paramNameDesC = paramNameStr.DesC(); |
|
1648 paramName16.Copy(paramNameDesC.Left(KMaxHeaderNameLen)); |
|
1649 if (hdr.GetParam(fieldNameStr,paramNameStr,paramVal) == KErrNone) |
|
1650 { |
|
1651 switch (paramVal.Type()) |
|
1652 { |
|
1653 case THTTPHdrVal::KStrFVal: |
|
1654 { |
|
1655 RStringF paramValStr = iStringPool.StringF(paramVal.StrF()); |
|
1656 const TDesC8& paramValDesC = paramValStr.DesC(); |
|
1657 paramVal16.Copy(paramValDesC.Left(KMaxHeaderValueLen)); |
|
1658 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("%S: %S"), ¶mName16, ¶mVal16)); |
|
1659 } |
|
1660 break; |
|
1661 case THTTPHdrVal::KStrVal: |
|
1662 { |
|
1663 RString paramValStr = iStringPool.String(paramVal.Str()); |
|
1664 const TDesC8& paramValDesC = paramValStr.DesC(); |
|
1665 paramVal16.Copy(paramValDesC.Left(KMaxHeaderValueLen)); |
|
1666 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("%S: %S"), ¶mName16, ¶mVal16)); |
|
1667 } |
|
1668 break; |
|
1669 default: |
|
1670 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("%S: <unrecognised value type>"), ¶mName16)); |
|
1671 break; |
|
1672 } |
|
1673 } |
|
1674 _LIT(KMultipartRelated,"Multipart/Related"); |
|
1675 _LIT(KApplication,"application/xop+xml"); |
|
1676 if ((fieldVal16 == KMultipartRelated) && (paramVal16 == KApplication)) |
|
1677 { |
|
1678 iXopResponse = ETrue; |
|
1679 } |
|
1680 |
|
1681 // Display realm for WWW-Authenticate header |
|
1682 RStringF wwwAuth = |
|
1683 iStringPool.StringF( |
|
1684 HTTP::EWWWAuthenticate,RHTTPSession::GetTable()); |
|
1685 if (fieldNameStr == wwwAuth) |
|
1686 { |
|
1687 // check the auth scheme is 'basic' |
|
1688 RStringF basic = |
|
1689 iStringPool.StringF(HTTP::EBasic,RHTTPSession::GetTable()); |
|
1690 RStringF realm = |
|
1691 iStringPool.StringF(HTTP::ERealm,RHTTPSession::GetTable()); |
|
1692 THTTPHdrVal realmVal; |
|
1693 if ((fieldVal.StrF() == basic) && |
|
1694 (!hdr.GetParam(wwwAuth, realm, realmVal))) |
|
1695 { |
|
1696 RStringF realmValStr = |
|
1697 iStringPool.StringF(realmVal.StrF()); |
|
1698 const TDesC8& realmValDesC = realmValStr.DesC(); |
|
1699 fieldVal16.Copy(realmValDesC.Left(KMaxHeaderValueLen)); |
|
1700 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("Realm is: %S"), &fieldVal16)); |
|
1701 } |
|
1702 } |
|
1703 paramNameStr.Close(); |
|
1704 } |
|
1705 ++it; |
|
1706 } |
|
1707 } |
|
1708 #else |
|
1709 // do nothing |
|
1710 void CSenHttpChannelImpl::DumpRespHeadersL(RHTTPTransaction& /* aTrans */) { } |
|
1711 #endif |
|
1712 |
|
1713 |
|
1714 // This is second debug logging method |
|
1715 //Do a formatted dump of binary data |
|
1716 #ifdef _SENDEBUG |
|
1717 void CSenHttpChannelImpl::DumpBodyData(const TDesC8& aData) |
|
1718 { |
|
1719 // Iterate the supplied block of data in blocks of cols=80 bytes |
|
1720 const TInt cols=16; |
|
1721 TInt pos = 0; |
|
1722 TBuf<KMaxFileName - 2> logLine; |
|
1723 TBuf<KMaxFileName - 2> anEntry; |
|
1724 const TInt dataLength = aData.Length(); |
|
1725 while (pos < dataLength) |
|
1726 { |
|
1727 //start-line hexadecimal( a 4 digit number) |
|
1728 anEntry.Format(TRefByValue<const TDesC>_L("%04x : "), pos); |
|
1729 logLine.Append(anEntry); |
|
1730 |
|
1731 // Hex output |
|
1732 TInt offset; |
|
1733 for (offset = 0; offset < cols; ++offset) |
|
1734 { |
|
1735 if (pos + offset < aData.Length()) |
|
1736 { |
|
1737 TInt nextByte = aData[pos + offset]; |
|
1738 anEntry.Format(TRefByValue<const TDesC>_L("%02x "), nextByte); |
|
1739 logLine.Append(anEntry); |
|
1740 } |
|
1741 else |
|
1742 { |
|
1743 // fill the remaining spaces with |
|
1744 // blanks untill the cols-th Hex number |
|
1745 anEntry.Format(TRefByValue<const TDesC>_L(" ")); |
|
1746 logLine.Append(anEntry); |
|
1747 } |
|
1748 } |
|
1749 anEntry.Format(TRefByValue<const TDesC>_L(": ")); |
|
1750 logLine.Append(anEntry); |
|
1751 |
|
1752 // Char output |
|
1753 for (offset = 0; offset < cols; ++offset) |
|
1754 { |
|
1755 if (pos + offset < aData.Length()) |
|
1756 { |
|
1757 TInt nextByte = aData[pos + offset]; |
|
1758 if ((nextByte >= ' ') && (nextByte <= '~')) |
|
1759 { |
|
1760 anEntry.Format(TRefByValue<const TDesC>_L("%c"), nextByte); |
|
1761 logLine.Append(anEntry); |
|
1762 } |
|
1763 else |
|
1764 { |
|
1765 anEntry.Format(TRefByValue<const TDesC>_L(".")); |
|
1766 logLine.Append(anEntry); |
|
1767 } |
|
1768 } |
|
1769 else |
|
1770 { |
|
1771 anEntry.Format(TRefByValue<const TDesC>_L(" ")); |
|
1772 logLine.Append(anEntry); |
|
1773 } |
|
1774 } |
|
1775 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, TRefByValue<const TDesC>_L("%S"), &logLine)); |
|
1776 logLine.Zero(); |
|
1777 |
|
1778 // Advance to next byte segment (1 seg= cols) |
|
1779 pos += cols; |
|
1780 } |
|
1781 } |
|
1782 #else |
|
1783 // do nothing |
|
1784 void CSenHttpChannelImpl::DumpBodyData(const TDesC8& /* aData */) { } |
|
1785 #endif |
|
1786 |
|
1787 // ---------------------------------------------------------------------------- |
|
1788 // CSenHttpChannelImpl::AppendNewTxnStateL |
|
1789 // ---------------------------------------------------------------------------- |
|
1790 // |
|
1791 void CSenHttpChannelImpl::AppendNewTxnStateL(CSenTxnState* aTxnState) |
|
1792 { |
|
1793 TLSLOG(KSenHttpChannelLogChannelBase , KMinLogLevel,(_L("CSenHttpChannelImpl::AppendNewTxnStateL"))); |
|
1794 iTxnStates->AppendL(aTxnState); |
|
1795 } |
|
1796 |
|
1797 // ---------------------------------------------------------------------------- |
|
1798 // CSenHttpChannelImpl::DeleteTxnState |
|
1799 // ---------------------------------------------------------------------------- |
|
1800 void CSenHttpChannelImpl::DeleteTxnState(TInt aTxnId) |
|
1801 { |
|
1802 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("CSenHttpChannelImpl::DeleteTxnState( %d )"), aTxnId)); |
|
1803 TInt index; |
|
1804 CSenTxnState* pTxnState = FindTxnState(aTxnId, &index); |
|
1805 if(pTxnState) |
|
1806 { |
|
1807 iTxnStates->Delete(index); |
|
1808 delete pTxnState; |
|
1809 pTxnState = NULL; |
|
1810 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("TxnState ( %d ) deleted"), aTxnId)); |
|
1811 } |
|
1812 } |
|
1813 |
|
1814 // ---------------------------------------------------------------------------- |
|
1815 // CSenHttpChannelImpl::FindTxnState |
|
1816 // ---------------------------------------------------------------------------- |
|
1817 CSenTxnState* CSenHttpChannelImpl::FindTxnState(TInt aTxnId, TInt* aIndex) |
|
1818 { |
|
1819 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("CSenHttpChannelImpl::FindTxnState( %d )"), aTxnId)); |
|
1820 for(TInt i = 0; i < iTxnStates->Count(); ++i) |
|
1821 { |
|
1822 if((*iTxnStates)[i]->Id() == aTxnId) |
|
1823 { |
|
1824 if(aIndex) |
|
1825 { |
|
1826 *aIndex = i; |
|
1827 } |
|
1828 return (*iTxnStates)[i]; |
|
1829 } |
|
1830 } |
|
1831 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("TxnState ( %d ) not found"), aTxnId)); |
|
1832 return NULL; |
|
1833 } |
|
1834 |
|
1835 |
|
1836 // @return KErrNone, if cancel was performed |
|
1837 // KErrNotFound if transaction was not found |
|
1838 TInt CSenHttpChannelImpl::CancelTransaction(const TInt aTxnId) |
|
1839 { |
|
1840 TLSLOG_L(KSenHttpChannelLogChannelBase , KSenHttpChannelLogLevel,""); |
|
1841 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("CSenHttpChannelImpl::CancelTransaction - TxnId: %d"), |
|
1842 aTxnId)); |
|
1843 |
|
1844 CSenTxnState* pTxnState = FindTxnState(aTxnId); |
|
1845 if(pTxnState) |
|
1846 { |
|
1847 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"- Txn found, calling Cancel():"); |
|
1848 return pTxnState->Cancel(); |
|
1849 } |
|
1850 return KErrNotFound; |
|
1851 } |
|
1852 |
|
1853 void CSenHttpChannelImpl::CancelAllTransactions() |
|
1854 { |
|
1855 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"CSenHttpChannelImpl::CancelAllTransaction"); |
|
1856 |
|
1857 for(TInt i = 0; i < iTxnStates->Count(); ++i) |
|
1858 { |
|
1859 (*iTxnStates)[i]->Cancel(); |
|
1860 } |
|
1861 } |
|
1862 |
|
1863 void CSenHttpChannelImpl::SetExplicitIapDefined(TBool aExplicitIapDefined) |
|
1864 { |
|
1865 iExplicitIapDefined = aExplicitIapDefined; |
|
1866 } |
|
1867 |
|
1868 |
|
1869 TBool CSenHttpChannelImpl::EffectiveIapId( TUint32 &aIapId ) |
|
1870 { |
|
1871 TInt handle = iConnection.SubSessionHandle(); |
|
1872 if (handle>0) |
|
1873 { |
|
1874 TUint connEnum(0); |
|
1875 TInt err = iConnection.EnumerateConnections(connEnum); |
|
1876 if (!err && !connEnum) |
|
1877 { |
|
1878 return EFalse; |
|
1879 } |
|
1880 } |
|
1881 |
|
1882 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("CSenHttpChannelImpl::EffectiveIapId(): Current RConnection's subsession handle(%d)"), iIapId )); |
|
1883 #ifdef _SENDEBUG |
|
1884 if( iExplicitIapDefined ) |
|
1885 { |
|
1886 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8(" - IAP ID is known: %d"), iIapId )); |
|
1887 } |
|
1888 else |
|
1889 { |
|
1890 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel," - IAP ID is not known."); |
|
1891 } |
|
1892 |
|
1893 if( handle < KErrNone ) |
|
1894 { |
|
1895 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel," -> RConnection has not been initialized."); |
|
1896 } |
|
1897 #endif // _SENDEBUG |
|
1898 |
|
1899 if( handle && !iExplicitIapDefined ) |
|
1900 { |
|
1901 // Eventhough IAP was not explicitely set (through Serene API), this |
|
1902 // code can check what IAP end-user provided via IAP selection dialog: |
|
1903 TLSLOG_L(KSenHttpChannelLogChannelBase , KMinLogLevel,"CSenHttpChannelImpl::EffectiveIapId: about to call RConnection::GetIntSetting()"); |
|
1904 _LIT( KIapIdKey, "IAP\\Id" ); |
|
1905 iConnection.GetIntSetting( KIapIdKey, iIapId); |
|
1906 if ( iIapId > 0 ) |
|
1907 { |
|
1908 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("CSenHttpChannelImpl::EffectiveIapId(): end-user provided IAP(%d)"), iIapId )); |
|
1909 // Treat the end-user selection as "explicit" definition as well(!): |
|
1910 iExplicitIapDefined = ETrue; |
|
1911 } |
|
1912 } |
|
1913 if( iExplicitIapDefined ) |
|
1914 { |
|
1915 aIapId = iIapId; |
|
1916 } |
|
1917 return iExplicitIapDefined; |
|
1918 } |
|
1919 |
|
1920 void CSenHttpChannelImpl::EnableTimeOutL(TInt aTxnId, TInt aTimeOutSec) |
|
1921 { |
|
1922 CSenTxnState* txn = FindTxnState(aTxnId); |
|
1923 if (txn) |
|
1924 txn->EnableTimeOutL(aTimeOutSec); |
|
1925 } |
|
1926 void CSenHttpChannelImpl::DisableTimeOutL(TInt aTxnId) |
|
1927 { |
|
1928 CSenTxnState* txn = FindTxnState(aTxnId); |
|
1929 if (txn) |
|
1930 txn->DisableTimeOutL(); |
|
1931 } |
|
1932 |
|
1933 TInt32 CSenHttpChannelImpl::UsedIap() |
|
1934 { |
|
1935 return iUsedIapId; |
|
1936 } |
|
1937 // END OF FILE |
|
1938 |
|
1939 |