|
1 // Copyright (c) 2002-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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // $Header$ |
|
15 // This module implements the collection of HTTP Transaction test classes |
|
16 // by: mjdavey, symbian@mjdss.com, August 2002 |
|
17 // for: Typhoon (7.0s) & JetStream (8.0) |
|
18 // Include Files |
|
19 // |
|
20 // |
|
21 |
|
22 #include <e32base.h> |
|
23 #include "CHTTPFamily.h" |
|
24 #include "HttpFrmwrk.h" |
|
25 #include "HttpTransactionCmds.h" |
|
26 #include "httptransaction.h" |
|
27 |
|
28 |
|
29 //----------------------------------------------------------------------------- |
|
30 //----------------------------------------------------------------------------- |
|
31 // Command: TRANSACTION command. |
|
32 //----------------------------------------------------------------------------- |
|
33 //----------------------------------------------------------------------------- |
|
34 // |
|
35 // Form(s): |
|
36 // TRANSACTION <connection name> <method> |
|
37 // TRANSACTION <connection name> <method> <URI> |
|
38 // Example: |
|
39 // a) TRANSACTION framework1 get $URI$ |
|
40 // b) TRANSACTION framework2 get "http://news.bbc.co.uk/nol/shared/img/global_toolbar/logo.gif" |
|
41 // c) TRANSACTION framework2 post |
|
42 // |
|
43 // this assumes that <connection name> has already been defined (see CONNECT) |
|
44 // examp a) assumes that define URI has already been created (see DEFINE) |
|
45 // examp b) is full form |
|
46 // examp c) is for post and will be detailed later |
|
47 |
|
48 CCmdTransaction *CCmdTransaction::NewL(TInt aCommandId, const TDesC& aKeyphrase, const TDesC& aHelpPhrase) |
|
49 { |
|
50 CCmdTransaction *self = NewLC( aCommandId, aKeyphrase, aHelpPhrase); |
|
51 CleanupStack::Pop(); |
|
52 return self; |
|
53 } |
|
54 |
|
55 //----------------------------------------------------------------------------- |
|
56 |
|
57 CCmdTransaction *CCmdTransaction::NewLC(TInt aCommandId, const TDesC& aKeyphrase, const TDesC& aHelpPhrase) |
|
58 { |
|
59 CCmdTransaction *self = new (ELeave) CCmdTransaction(); |
|
60 CleanupStack::PushL( self ); |
|
61 self->ConstructL(aCommandId, aKeyphrase, aHelpPhrase); |
|
62 return self; |
|
63 } |
|
64 |
|
65 //----------------------------------------------------------------------------- |
|
66 |
|
67 void CCmdTransaction::ConstructL(TInt aCommandId, const TDesC& aKeyphrase, const TDesC& aHelpPhrase) |
|
68 { |
|
69 CCmdBase::ConstructL(aCommandId, aKeyphrase, aHelpPhrase); |
|
70 |
|
71 // set local vars for convenience |
|
72 iTransactionIndex = -1; |
|
73 iExpectedError = 0; |
|
74 iExpectError = EFalse; |
|
75 iTestFail = 0; |
|
76 iExpectedStatusCode = 200; |
|
77 eStrIndex = HTTP::ECONNECT; |
|
78 iHasARequestBody = EFalse; |
|
79 iExpectedNumberRedirects = 0; |
|
80 } |
|
81 |
|
82 //----------------------------------------------------------------------------- |
|
83 |
|
84 CCmdTransaction::~CCmdTransaction(void) {} |
|
85 |
|
86 //----------------------------------------------------------------------------- |
|
87 // This must have three parameters: <connection tagname> <methodname> and <uri> |
|
88 // the tagname must be checked against existing valid tags and the methodname |
|
89 // against a list of our creation. the URI may be an existing define or |
|
90 // a string |
|
91 |
|
92 TInt CCmdTransaction::ProcessL(const TDesC& aCommand) |
|
93 { |
|
94 |
|
95 // Complete the test machine - will then get the next cmd |
|
96 Machine()->CompleteRequest(); |
|
97 |
|
98 TPtrC transname; |
|
99 TPtrC conname; |
|
100 TPtrC transmthd; |
|
101 TPtrC transURI; |
|
102 TPtrC postData; |
|
103 |
|
104 TInt error; |
|
105 // ParseCmdArgs indirectly sets eStrIndex |
|
106 |
|
107 if (( error = ParseCmdArgs( aCommand, |
|
108 transname, |
|
109 conname, |
|
110 transmthd, |
|
111 transURI, |
|
112 postData)) != KErrNone) |
|
113 return error; |
|
114 |
|
115 if (conname.Size() == 0) |
|
116 { |
|
117 (void) ShowTransactions () ; |
|
118 return error; |
|
119 } |
|
120 |
|
121 // Get the session object we need |
|
122 // If it is return error, if not create a session and ptr! |
|
123 |
|
124 CAnyObject *cnx = (CAnyObject *)Machine()->Domains()->Name(conname); |
|
125 |
|
126 if (cnx == NULL)// does not already exists |
|
127 return Error(KErrArgument, THA_KErrInvalidConnect, &conname); |
|
128 else |
|
129 { |
|
130 // reset the received status |
|
131 iReceivedError = -1; |
|
132 |
|
133 CFrmwrkSession *myConnection = (CFrmwrkSession *) cnx->Ptr(); |
|
134 // TPtrC myName = myConnection->Name() ; |
|
135 |
|
136 RHTTPSession mySession = myConnection->Session(); |
|
137 |
|
138 CTestTransaction *transaction = NULL; |
|
139 |
|
140 TRAPD(err, transaction = CTestTransaction::NewL( mySession, |
|
141 eStrIndex, |
|
142 transURI, |
|
143 postData, |
|
144 transname, |
|
145 Machine())); |
|
146 if (err != KErrNone) |
|
147 { |
|
148 Log(_L("Failed to create Transaction %S"), &transname); |
|
149 return err; |
|
150 } |
|
151 else |
|
152 { |
|
153 Log(_L("Transaction %S created successfully"), &transname); |
|
154 } |
|
155 |
|
156 TRAP ( err, transaction->SubmitL()); |
|
157 |
|
158 if (err != KErrNone) |
|
159 { |
|
160 Log(_L("Transaction %S, Submission failed"), &transname); |
|
161 return err; |
|
162 } |
|
163 else |
|
164 { |
|
165 Log(_L("Transaction %S, Submission succeeded"), &transname); |
|
166 } |
|
167 |
|
168 |
|
169 Machine()->Domains()->AddL(transname, eStrIndex, THA_KHTTP_Transaction, (TAny *) transaction); |
|
170 } |
|
171 |
|
172 if (error != KErrNone) |
|
173 Log(TFR_KFmtErrFailed, &Keyphrase(), error); |
|
174 |
|
175 return error; |
|
176 } |
|
177 |
|
178 //----------------------------------------------------------------------------- |
|
179 |
|
180 TInt CCmdTransaction::ParseCmdArgs( const TDesC& aCommand, |
|
181 TPtrC& aTransName, |
|
182 TPtrC& aConName, |
|
183 TPtrC& aTransMthd, |
|
184 TPtrC& aTransURI, |
|
185 TPtrC& aPostData) |
|
186 { |
|
187 aConName.Set(NULL, 0); |
|
188 aTransName.Set(NULL, 0); |
|
189 aTransMthd.Set(NULL, 0); |
|
190 aTransURI.Set(NULL, 0); |
|
191 aPostData.Set(NULL, 0); |
|
192 |
|
193 // get the command into a local string |
|
194 TPtrC param; |
|
195 TInt error = KErrNone; |
|
196 TRAP(error, param.Set( ParamsL(aCommand))); |
|
197 if (error != KErrNone) |
|
198 return Error(error, TFR_KFmtErrBadCmd, &Keyphrase()); |
|
199 |
|
200 // check its' valid |
|
201 TLex parse(param); |
|
202 if (!parse.Eos() && !parse.Peek().IsSpace()) |
|
203 return Error(error, TFR_KFmtErrBadCmd, &parse); |
|
204 |
|
205 // remove any spaces and see if its got params |
|
206 parse.SkipSpace(); |
|
207 if (parse.Eos()) // If no params, print out present connections. |
|
208 return error; |
|
209 |
|
210 //----------------------------- |
|
211 // Get transaction name, must not exceed 16 characters. |
|
212 |
|
213 TRAP(error, aTransName.Set(TfrLex::GetL(parse))); |
|
214 if ( error != KErrNone) |
|
215 return Error(KErrArgument, TFR_KFmtErrBadCmd, &aTransName); |
|
216 |
|
217 // check transaction name is valid length |
|
218 aTransName.Set(TfrLex::Peel(aTransName)); |
|
219 |
|
220 if (aTransName.Length() > 16) |
|
221 return Error(KErrArgument, THA_KErrParameterLong, &aTransName); |
|
222 |
|
223 if (aTransName.Length() <= 0) |
|
224 return Error(KErrArgument, TFR_KFmtErrMissingParams, &Keyphrase()); |
|
225 |
|
226 CAnyObject *cnx = (CAnyObject *)Machine()->Domains()->Name(aTransName); |
|
227 |
|
228 if (cnx != NULL) // already exists |
|
229 return Error(KErrAlreadyExists, THA_KErrCnxionExists, &aTransName); |
|
230 |
|
231 |
|
232 //----------------------------- |
|
233 // Get framework name, must not exceed 16 characters. |
|
234 // should be http or wsp (currently) |
|
235 |
|
236 TRAP(error, aConName.Set(TfrLex::GetL(parse))); |
|
237 if ( error != KErrNone) |
|
238 return Error(KErrArgument, TFR_KFmtErrBadCmd, &aConName); |
|
239 |
|
240 // check connection name is valid length |
|
241 aConName.Set(TfrLex::Peel(aConName)); |
|
242 if (aConName.Length() > 16) |
|
243 return Error(KErrArgument, THA_KErrParameterLong, &aConName); |
|
244 |
|
245 if (aConName.Length() <= 0) |
|
246 return Error(KErrArgument, TFR_KFmtErrMissingParams, &Keyphrase()); |
|
247 |
|
248 // check connection name exists |
|
249 if (!checkConnectionExists(aConName)) |
|
250 return Error(KErrArgument, THA_KErrConnectionNotExists, &aConName); |
|
251 |
|
252 //----------------------------- |
|
253 // Get method value. |
|
254 TRAP(error, aTransMthd.Set(TfrLex::GetL(parse))); |
|
255 if (error != KErrNone) |
|
256 return Error(KErrArgument, TFR_KFmtErrBadCmd, &aTransMthd); |
|
257 |
|
258 // check method name is valid length |
|
259 aTransMthd.Set(TfrLex::Peel(aTransMthd)); |
|
260 if (aTransMthd.Length() > 16) |
|
261 return Error(KErrArgument, THA_KErrParameterLong, &aTransMthd); |
|
262 |
|
263 if (aTransMthd.Length() <= 0) |
|
264 return Error(KErrArgument, TFR_KFmtErrMissingParams, &Keyphrase()); |
|
265 |
|
266 // check method defined |
|
267 if (!checkMethodExists(aTransMthd)) |
|
268 return Error(KErrArgument, THA_KErrMethodNotExists, &aTransMthd); |
|
269 |
|
270 //----------------------------- |
|
271 // Get URI value. |
|
272 |
|
273 TRAP(error, aTransURI.Set(TfrLex::GetL(parse))); |
|
274 if (error != KErrNone) |
|
275 return Error(KErrArgument, TFR_KFmtErrBadCmd, &aTransURI); |
|
276 |
|
277 // uri's may be enormous so lets not bother worrying about length! |
|
278 aTransURI.Set(TfrLex::Peel(aTransURI)); |
|
279 |
|
280 if (aTransURI.Length() <= 0) |
|
281 return Error(KErrArgument, TFR_KFmtErrMissingParams, &Keyphrase()); |
|
282 |
|
283 //----------------------------- |
|
284 // Get Additional Parameters |
|
285 // some commands (e.g. POST) may require an additional parameter |
|
286 // to provide either filename (for source data) or block of text |
|
287 // for posting... |
|
288 |
|
289 TRAP(error, aPostData.Set(TfrLex::GetL(parse))); |
|
290 if (error != KErrNone) |
|
291 return Error(KErrArgument, TFR_KFmtErrBadCmd, &aPostData); |
|
292 |
|
293 // datablocks and filenames may be enormous so lets not bother worrying about length! |
|
294 aPostData.Set(TfrLex::Peel(aPostData)); |
|
295 |
|
296 //----------------------------- |
|
297 // There should not be anything more (currently) |
|
298 // Future additions MAY required optional parameters and therefore the following may |
|
299 // need to be dumped... |
|
300 |
|
301 TPtrC remainder = TfrLex::Trim(parse.Remainder()); |
|
302 if (remainder.Length() > 0) |
|
303 return Error(KErrArgument, TFR_KFmtErrBadCmd, &remainder); |
|
304 |
|
305 aConName.Set(TfrLex::Peel(aConName)); |
|
306 return (KErrNone); |
|
307 } |
|
308 |
|
309 void CCmdTransaction::ShowTransactions() |
|
310 { |
|
311 TInt iTrans = 0; |
|
312 |
|
313 CObjCatalogue *trnsctns = Machine()->Domains(); |
|
314 Log(_L("\tCurrent Transactions:")); |
|
315 Log(_L("\tName \tMethod \tURI")); |
|
316 for (TInt i = 0; i < trnsctns->Count(); ++i) |
|
317 { |
|
318 CAnyObject *obj = (CAnyObject *)trnsctns->At(i); |
|
319 if (obj->Tag() == THA_KHTTP_Transaction) |
|
320 { |
|
321 TPtrC label = obj->Name(); |
|
322 TInt eStrIndex = obj->Index(); |
|
323 CTestTransaction *trans = (CTestTransaction *)obj->Ptr(); |
|
324 TBuf<256> uri; |
|
325 uri.Copy (trans->Uri()) ; |
|
326 |
|
327 TPtrC mthd; |
|
328 |
|
329 switch (eStrIndex) |
|
330 { |
|
331 case HTTP::EGET : mthd.Set(THA_TxtCmdTransactionGET); break; |
|
332 case HTTP::EPOST : mthd.Set(THA_TxtCmdTransactionPOST); break; |
|
333 case HTTP::EPUT : mthd.Set(THA_TxtCmdTransactionPUT); break; |
|
334 case HTTP::EDELETE : mthd.Set(THA_TxtCmdTransactionDELETE); break; |
|
335 case HTTP::EHEAD : mthd.Set(THA_TxtCmdTransactionHEAD); break; |
|
336 case HTTP::EOPTIONS : mthd.Set(THA_TxtCmdTransactionOPTIONS); break; |
|
337 case HTTP::ETRACE : mthd.Set(THA_TxtCmdTransactionTRACE); break; |
|
338 default : break; |
|
339 } |
|
340 ++iTrans; |
|
341 Log(_L("\t%d\t%S\t%S\t%S"), iTrans, |
|
342 &label, |
|
343 &mthd, |
|
344 &uri); |
|
345 } |
|
346 } |
|
347 if (iTrans == 0) |
|
348 Log(_L("\tNo transactions have been defined")); |
|
349 } |
|
350 |
|
351 //----------------------------------------------------------------------------- |
|
352 // check connection name exists |
|
353 // we have to connect to the object catalogue and look at sessions! |
|
354 |
|
355 TBool CCmdTransaction::checkConnectionExists(TPtrC &aName) |
|
356 { |
|
357 CObjCatalogue *sessions = Machine()->Domains(); |
|
358 for (TInt i = 0; i < sessions->Count(); ++i) |
|
359 { |
|
360 CAnyObject *obj = (CAnyObject *)sessions->At(i); |
|
361 if (obj->Tag() == THA_KHTTP_Connect) |
|
362 { |
|
363 TPtrC sessname = obj->Name(); |
|
364 if (sessname.CompareF(aName) == 0) |
|
365 return ETrue; |
|
366 } |
|
367 } |
|
368 |
|
369 return EFalse; |
|
370 } |
|
371 |
|
372 |
|
373 //----------------------------------------------------------------------------- |
|
374 // check method name exists |
|
375 // we have to compare supplied name to our existing list of method |
|
376 // use crude compare for now, but perhaps add more elegant list facility?! |
|
377 // the enums are from HttpStringConstants.h and should not be interferred with!!! |
|
378 |
|
379 TBool CCmdTransaction::checkMethodExists(TPtrC &aName) |
|
380 { |
|
381 if (aName.CompareF(THA_TxtCmdTransactionGET) == 0) |
|
382 { |
|
383 eStrIndex = HTTP::EGET; |
|
384 return ETrue; |
|
385 } |
|
386 else if (aName.CompareF(THA_TxtCmdTransactionPOST) == 0) |
|
387 { |
|
388 eStrIndex = HTTP::EPOST; |
|
389 return ETrue; |
|
390 } |
|
391 else if (aName.CompareF(THA_TxtCmdTransactionPUT) == 0) |
|
392 { |
|
393 eStrIndex = HTTP::EPUT; |
|
394 return ETrue; |
|
395 } |
|
396 else if (aName.CompareF(THA_TxtCmdTransactionHEAD) == 0) |
|
397 { |
|
398 eStrIndex = HTTP::EHEAD; |
|
399 return ETrue; |
|
400 } |
|
401 else if (aName.CompareF(THA_TxtCmdTransactionDELETE) == 0) |
|
402 { |
|
403 eStrIndex = HTTP::EDELETE; |
|
404 return ETrue; |
|
405 } |
|
406 else if (aName.CompareF(THA_TxtCmdTransactionOPTIONS) == 0) |
|
407 { |
|
408 eStrIndex = HTTP::EOPTIONS; |
|
409 return ETrue; |
|
410 } |
|
411 else if (aName.CompareF(THA_TxtCmdTransactionTRACE) == 0) |
|
412 { |
|
413 eStrIndex = HTTP::ETRACE; |
|
414 return ETrue; |
|
415 } |
|
416 |
|
417 return EFalse; |
|
418 } |
|
419 |
|
420 |
|
421 CCmdEndTransaction *CCmdEndTransaction::NewL(TInt aCommandId, const TDesC& aKeyphrase, const TDesC& aHelpPhrase) |
|
422 { |
|
423 CCmdEndTransaction *self = NewLC( aCommandId, aKeyphrase, aHelpPhrase); |
|
424 CleanupStack::Pop(); |
|
425 return self; |
|
426 } |
|
427 |
|
428 //----------------------------------------------------------------------------- |
|
429 |
|
430 CCmdEndTransaction *CCmdEndTransaction::NewLC(TInt aCommandId, const TDesC& aKeyphrase, const TDesC& aHelpPhrase) |
|
431 { |
|
432 CCmdEndTransaction *self = new (ELeave) CCmdEndTransaction(); |
|
433 CleanupStack::PushL( self ); |
|
434 self->ConstructL(aCommandId, aKeyphrase, aHelpPhrase); |
|
435 return self; |
|
436 } |
|
437 |
|
438 //----------------------------------------------------------------------------- |
|
439 |
|
440 void CCmdEndTransaction::ConstructL(TInt aCommandId, const TDesC& aKeyphrase, const TDesC& aHelpPhrase) |
|
441 { |
|
442 CCmdBase::ConstructL(aCommandId, aKeyphrase, aHelpPhrase); |
|
443 } |
|
444 |
|
445 //----------------------------------------------------------------------------- |
|
446 |
|
447 CCmdEndTransaction::~CCmdEndTransaction(void) {} |
|
448 |
|
449 //----------------------------------------------------------------------------- |
|
450 |
|
451 TInt CCmdEndTransaction::ParseCmdArgs( const TDesC& aCommand, |
|
452 TPtrC& aTransName) |
|
453 { |
|
454 aTransName.Set(NULL, 0); |
|
455 |
|
456 // get the command into a local string |
|
457 TPtrC param; |
|
458 TInt error = KErrNone; |
|
459 TRAP(error, param.Set( ParamsL(aCommand))); |
|
460 if (error != KErrNone) |
|
461 return Error(error, TFR_KFmtErrBadCmd, &Keyphrase()); |
|
462 |
|
463 // check its' valid |
|
464 TLex parse(param); |
|
465 if (!parse.Eos() && !parse.Peek().IsSpace()) |
|
466 return Error(error, TFR_KFmtErrBadCmd, &parse); |
|
467 |
|
468 // remove any spaces and see if its got params |
|
469 parse.SkipSpace(); |
|
470 if (parse.Eos()) // If no params, print out present connections. |
|
471 return error; |
|
472 |
|
473 //----------------------------- |
|
474 // Get transaction name, must not exceed 16 characters. |
|
475 |
|
476 TRAP(error, aTransName.Set(TfrLex::GetL(parse))); |
|
477 if ( error != KErrNone) |
|
478 return Error(KErrArgument, TFR_KFmtErrBadCmd, &aTransName); |
|
479 |
|
480 // check transaction name is valid length |
|
481 aTransName.Set(TfrLex::Peel(aTransName)); |
|
482 |
|
483 if (aTransName.Length() > 16) |
|
484 return Error(KErrArgument, THA_KErrParameterLong, &aTransName); |
|
485 |
|
486 if (aTransName.Length() <= 0) |
|
487 return Error(KErrArgument, TFR_KFmtErrMissingParams, &Keyphrase()); |
|
488 |
|
489 return (KErrNone); |
|
490 } |
|
491 |
|
492 |
|
493 TInt CCmdEndTransaction::ProcessL(const TDesC& aCommand) |
|
494 { |
|
495 // Complete the test machine - will then get the next cmd |
|
496 Machine()->CompleteRequest(); |
|
497 |
|
498 TPtrC transname; |
|
499 |
|
500 TInt error = KErrNone; |
|
501 |
|
502 if (( error = ParseCmdArgs( aCommand, |
|
503 transname)) != KErrNone) |
|
504 return error; |
|
505 |
|
506 CAnyObject *obj = (CAnyObject *)Machine()->Domains()->Name(transname); |
|
507 |
|
508 if ((obj == NULL) || (obj->Tag() != THA_KHTTP_Transaction)) |
|
509 return Error(KErrArgument, THA_KErrInvalidTransaction, &transname); |
|
510 |
|
511 CTestTransaction *transaction = (CTestTransaction *) obj->Ptr(); |
|
512 |
|
513 transaction->CloseTransaction(); |
|
514 delete transaction; |
|
515 |
|
516 Machine()->Domains()->Delete(transname); |
|
517 |
|
518 return error; |
|
519 } |
|
520 |
|
521 CCmdShowTransaction *CCmdShowTransaction::NewL(TInt aCommandId, const TDesC& aKeyphrase, const TDesC& aHelpPhrase) |
|
522 { |
|
523 CCmdShowTransaction *self = NewLC( aCommandId, aKeyphrase, aHelpPhrase); |
|
524 CleanupStack::Pop(); |
|
525 return self; |
|
526 } |
|
527 |
|
528 //----------------------------------------------------------------------------- |
|
529 |
|
530 CCmdShowTransaction *CCmdShowTransaction::NewLC(TInt aCommandId, const TDesC& aKeyphrase, const TDesC& aHelpPhrase) |
|
531 { |
|
532 CCmdShowTransaction *self = new (ELeave) CCmdShowTransaction(); |
|
533 CleanupStack::PushL( self ); |
|
534 self->ConstructL(aCommandId, aKeyphrase, aHelpPhrase); |
|
535 return self; |
|
536 } |
|
537 |
|
538 //----------------------------------------------------------------------------- |
|
539 |
|
540 void CCmdShowTransaction::ConstructL(TInt aCommandId, const TDesC& aKeyphrase, const TDesC& aHelpPhrase) |
|
541 { |
|
542 CCmdBase::ConstructL(aCommandId, aKeyphrase, aHelpPhrase); |
|
543 } |
|
544 |
|
545 //----------------------------------------------------------------------------- |
|
546 |
|
547 CCmdShowTransaction::~CCmdShowTransaction(void) {} |
|
548 |
|
549 //----------------------------------------------------------------------------- |
|
550 |
|
551 |
|
552 TInt CCmdShowTransaction::ProcessL(const TDesC& aCommand) |
|
553 { |
|
554 // Complete the test machine - will then get the next cmd |
|
555 Machine()->CompleteRequest(); |
|
556 |
|
557 TPtrC param; |
|
558 TInt error = KErrNone; |
|
559 TRAP(error, param.Set( ParamsL(aCommand))); |
|
560 if (error != KErrNone) |
|
561 return Error(error, TFR_KFmtErrBadCmd, &Keyphrase()); |
|
562 |
|
563 CObjCatalogue *trnsctns = Machine()->Domains(); |
|
564 TInt iTrans = 0; |
|
565 |
|
566 Log(_L("\tCurrent Transactions:")); |
|
567 Log(_L("\tName \tMethod \tURI")); |
|
568 for (TInt i = 0; i < trnsctns->Count(); ++i) |
|
569 { |
|
570 CAnyObject *obj = (CAnyObject *)trnsctns->At(i); |
|
571 if (obj->Tag() == THA_KHTTP_Transaction) |
|
572 { |
|
573 TPtrC label = obj->Name(); |
|
574 TInt eStrIndex = obj->Index(); |
|
575 CTestTransaction *trans = (CTestTransaction *)obj->Ptr(); |
|
576 TBuf<256> uri; |
|
577 uri.Copy (trans->Uri()) ; |
|
578 |
|
579 TPtrC mthd; |
|
580 |
|
581 switch (eStrIndex) |
|
582 { |
|
583 case HTTP::EGET : mthd.Set(THA_TxtCmdTransactionGET); break; |
|
584 case HTTP::EPOST : mthd.Set(THA_TxtCmdTransactionPOST); break; |
|
585 case HTTP::EPUT : mthd.Set(THA_TxtCmdTransactionPUT); break; |
|
586 case HTTP::EDELETE : mthd.Set(THA_TxtCmdTransactionDELETE); break; |
|
587 case HTTP::EHEAD : mthd.Set(THA_TxtCmdTransactionHEAD); break; |
|
588 case HTTP::EOPTIONS : mthd.Set(THA_TxtCmdTransactionOPTIONS); break; |
|
589 case HTTP::ETRACE : mthd.Set(THA_TxtCmdTransactionTRACE); break; |
|
590 default : break; |
|
591 } |
|
592 ++iTrans; |
|
593 // if (trans->iState == CTestTransaction::EActive) |
|
594 if (trans->State() == CTestTransaction::EActive) |
|
595 { |
|
596 Log(_L("\t%d\t%S\t%S\t%S"), iTrans, |
|
597 &label, |
|
598 &mthd, |
|
599 &uri); |
|
600 } |
|
601 } |
|
602 } |
|
603 if (iTrans == 0) |
|
604 Log(_L("\tNo transactions have been defined")); |
|
605 |
|
606 return KErrNone; |
|
607 |
|
608 } |
|
609 |
|
610 |
|
611 |
|
612 //----------------------------------------------------------------------------- |
|
613 // End of File |
|
614 //----------------------------------------------------------------------------- |
|
615 |