|
1 /* |
|
2 * Copyright (c) 2008 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 #include <ss_glob.h> |
|
19 #include <comms-infras/ss_nodemessages_factory.h> |
|
20 #include <comms-infras/ss_nodemessages_dataclient.h> |
|
21 #include <httpstringconstants.h> |
|
22 |
|
23 #include "ptcpclienttests.h" |
|
24 #include "upnp_cf_msgs.h" |
|
25 #include "upnpflowbase.h" |
|
26 #include "httpclientflow.h" |
|
27 #include "upnpflowfactory.h" |
|
28 |
|
29 #include <http/framework/cheadercodecplugin.h> |
|
30 #include <upnp/tupnptable.h> |
|
31 |
|
32 #include "CTcpClientTestUPnP9.h" |
|
33 #include "upnpserverconstants.h" |
|
34 |
|
35 //const TUint16 KActivityNull = 0; |
|
36 //const TUint KHttpDefaultPort = 80; |
|
37 |
|
38 |
|
39 const TUint KTransactionCount = 1; |
|
40 _LIT8 ( KTxtRawRequest, "POST / HTTP/1.1\r\nHost: 127.0.0.1:80\r\nExpect: 100-Continue\r\nContent-Length: 330\r\n\r\n<?xml version=\"1.0\" encoding=\"utf-8\"?><s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:QueryStateVariableResponse xmlns:u=\"urn:shemas-upnp-org:control-1-0\"><return>Query return value</return></u:QueryStateVariableResponse></s:Body></s:Envelope>" ); |
|
41 _LIT8 ( KTxtRawResponse, "HTTP/1.1 200 OK\r\nContent-Length: 330\r\n\r\n<?xml version=\"1.0\" encoding=\"utf-8\"?><s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:QueryStateVariableResponse xmlns:u=\"urn:shemas-upnp-org:control-1-0\"><return>Query return value</return></u:QueryStateVariableResponse></s:Body></s:Envelope>\r\n\r\n" ); |
|
42 _LIT8 ( KBodyData, "<?xml version=\"1.0\" encoding=\"utf-8\"?><s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:QueryStateVariableResponse xmlns:u=\"urn:shemas-upnp-org:control-1-0\"><return>Query return value</return></u:QueryStateVariableResponse></s:Body></s:Envelope>" ); |
|
43 |
|
44 CTcpClientTestUPnP9* CTcpClientTestUPnP9::NewL ( CProxyProvd* aProvd ) |
|
45 { |
|
46 CTcpClientTestUPnP9* ret = new ( ELeave ) CTcpClientTestUPnP9 ( aProvd ); |
|
47 CleanupStack::PushL ( ret ); |
|
48 ret->ConstructL (); |
|
49 CleanupStack::Pop ( ret ); |
|
50 return ret; |
|
51 } |
|
52 |
|
53 CTcpClientTestUPnP9::CTcpClientTestUPnP9 ( CProxyProvd* aProvd ) : |
|
54 CTcpClientTestBase(aProvd), iTestServer(NULL) |
|
55 { |
|
56 } |
|
57 |
|
58 CTcpClientTestUPnP9::~CTcpClientTestUPnP9 () |
|
59 { |
|
60 iTimer.Close (); |
|
61 delete iCodec; |
|
62 iStringPool.Close(); |
|
63 delete iClientHandler; |
|
64 delete iTransaction; |
|
65 } |
|
66 |
|
67 void CTcpClientTestUPnP9::ConstructL() |
|
68 { |
|
69 iTimer.CreateLocal (); |
|
70 iStringPool.OpenL( TUPnPTable::Table() ); |
|
71 iStringPool.OpenL(THTTPTable::Table()); |
|
72 iCodec = CHeaderCodecPlugin::NewL ( KUPnPCodecName, iStringPool ); |
|
73 } |
|
74 |
|
75 TVerdict CTcpClientTestUPnP9::RunTestL() |
|
76 { |
|
77 switch ( iState ) |
|
78 { |
|
79 case ECreateTestServer: |
|
80 { |
|
81 iLogger.WriteFormat(_L("<i>Creating TestServer..... </i>")); |
|
82 |
|
83 iTestServer = CTestTcpServer::NewL ( *this ); |
|
84 |
|
85 iState = ECreateTestClient; |
|
86 iStatus = KRequestPending; |
|
87 Reschedule(); |
|
88 return EPass; |
|
89 } |
|
90 |
|
91 case ECreateTestClient: |
|
92 { |
|
93 iLogger.WriteFormat(_L("<i>TestServer is created..... </i>")); |
|
94 iLogger.WriteFormat(_L("<i>Creating TestClient..... </i>")); |
|
95 |
|
96 |
|
97 |
|
98 TInetAddr remoteAddress( KInetAddrLoop, 80 ); |
|
99 iClientHandler = CHTTPClientHandler::NewL ( *this, iChunkManager, &remoteAddress ); |
|
100 iTransaction = PrepareTransactionL (); |
|
101 iClientHandler->SubmitTransaction( iTransaction ); |
|
102 |
|
103 iState = ESendRequestData; |
|
104 iStatus = KRequestPending; |
|
105 Reschedule(); |
|
106 return EPass; |
|
107 } |
|
108 |
|
109 case ESendRequestData: |
|
110 { |
|
111 return EPass; |
|
112 } |
|
113 |
|
114 case ECleanup: |
|
115 { |
|
116 delete iTestServer; |
|
117 |
|
118 // cleanup tcp client flow |
|
119 //delete reinterpret_cast<CHttpClientFlow*> ( iClientId.Ptr () ); |
|
120 iTimer.After ( iStatus, 60000000 ); //10 secs |
|
121 iState = EComplete; |
|
122 iStatus = KRequestPending; |
|
123 Reschedule (); |
|
124 return EPass; |
|
125 } |
|
126 case EComplete: |
|
127 { |
|
128 iLogger.WriteFormat(_L("<i>TestCase: Complete..... </i>")); |
|
129 return EPass; |
|
130 } |
|
131 |
|
132 default: |
|
133 iLogger.WriteFormat(_L("<i> Failed: TestCase:..... </i>")); |
|
134 ASSERT(0); |
|
135 return EFail; |
|
136 } |
|
137 } |
|
138 |
|
139 |
|
140 CHTTPClientTransaction* CTcpClientTestUPnP9::PrepareTransactionL () |
|
141 { |
|
142 TNodeCtxId channelId ( MeshMachine::KActivityNull, TNodeId::NullId() ); |
|
143 |
|
144 CHTTPClientTransaction* ctrans = CHTTPClientTransaction::NewL ( *iCodec, iStringPool, channelId ); |
|
145 |
|
146 CRequest* crequest = ctrans->Request( ); |
|
147 RHTTPHeaders headers = crequest->Handle( ).GetHeaderCollection ( ); |
|
148 RRequest rrequest = crequest->Handle( ); |
|
149 |
|
150 // Set request method |
|
151 RStringF stringF = iStringPool.StringF ( HTTP::EPOST, THTTPTable::Table() ); |
|
152 rrequest.SetMethod ( stringF ); |
|
153 |
|
154 // Set request Uri |
|
155 TUriParser8 uriPath; |
|
156 uriPath.Parse ( _L8 ("/") ); |
|
157 rrequest.SetURIL ( uriPath ); |
|
158 |
|
159 RStringF hostValStr = iStringPool.OpenFStringL( _L8("127.0.0.1:80")); |
|
160 THTTPHdrVal hostVal ( hostValStr ); |
|
161 headers.SetFieldL ( iStringPool.StringF ( HTTP::EHost, THTTPTable::Table() ), hostVal ); |
|
162 hostValStr.Close (); |
|
163 |
|
164 //Set Content Length |
|
165 THTTPHdrVal hdrVal ( 330 ); |
|
166 headers.SetFieldL ( iStringPool.StringF ( HTTP::EContentLength, THTTPTable::Table() ), hdrVal ); |
|
167 |
|
168 stringF = iStringPool.StringF ( HTTP::E100Continue, THTTPTable::Table() ); |
|
169 |
|
170 // 100-continue |
|
171 THTTPHdrVal hdrStr ( stringF ); |
|
172 headers.SetFieldL ( iStringPool.StringF ( HTTP::EExpect, THTTPTable::Table() ), hdrStr ); |
|
173 |
|
174 // Set Body Data |
|
175 RMBufChain buf; |
|
176 buf.CreateL( KBodyData); |
|
177 ctrans->AddBodyPart( buf ); |
|
178 ctrans->SetComplete (); |
|
179 |
|
180 stringF.Close (); |
|
181 return ctrans; |
|
182 } |
|
183 |
|
184 |
|
185 void CTcpClientTestUPnP9::OnTestServerEventL ( TInt aError ) |
|
186 { |
|
187 CompleteSelf ( aError ); |
|
188 } |
|
189 |
|
190 MTcpClientTestCase* CTcpClientTestUPnP9::GetTestCase () |
|
191 { |
|
192 return this; |
|
193 } |
|
194 |
|
195 CTestExecuteLogger& CTcpClientTestUPnP9::GetLogger ( ) |
|
196 { |
|
197 return iLogger; |
|
198 } |
|
199 |
|
200 |
|
201 const TDesC& CTcpClientTestUPnP9::TestCaseName () const |
|
202 { |
|
203 _LIT ( KTxtTitle, "Defect Fix CINC077703More" ); |
|
204 return KTxtTitle (); |
|
205 } |
|
206 |
|
207 TInt CTcpClientTestUPnP9::TotalTransactionCount () const |
|
208 { |
|
209 return KTransactionCount; |
|
210 } |
|
211 |
|
212 const TDesC8& CTcpClientTestUPnP9::GetRawRequest ( TInt aTransIndex ) |
|
213 { |
|
214 __ASSERT_ALWAYS ( aTransIndex < KTransactionCount, User::Invariant () ); |
|
215 return KTxtRawRequest (); |
|
216 } |
|
217 |
|
218 const TDesC8& CTcpClientTestUPnP9::GetRawResponse ( TInt aTransIndex ) |
|
219 { |
|
220 __ASSERT_ALWAYS( aTransIndex < KTransactionCount, User::Invariant () ); |
|
221 return KTxtRawResponse (); |
|
222 } |
|
223 |
|
224 TInt CTcpClientTestUPnP9::TransactionCount () const |
|
225 { |
|
226 return KTransactionCount; |
|
227 } |
|
228 |
|
229 |
|
230 TInt CTcpClientTestUPnP9::OnHttpEvent ( CTransaction* /*aTransaction*/, THTTPEvent& /*aEvent*/ ) |
|
231 { |
|
232 return KErrNone; |
|
233 } |
|
234 |
|
235 |
|
236 ///////////////////////////////////////////////////////////////////////////////////////////////// |
|
237 |
|
238 _LIT8 ( KTxtRawRequest1, "GET / HTTP/1.1\r\nHost: 127.0.0.1:80\r\n\r\n" ); |
|
239 _LIT8 ( KTxtRawResponse1, "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n" ); |
|
240 |
|
241 CTcpClientTestUPnP16* CTcpClientTestUPnP16::NewL ( CProxyProvd* aProvd ) |
|
242 { |
|
243 CTcpClientTestUPnP16* ret = new ( ELeave ) CTcpClientTestUPnP16 ( aProvd ); |
|
244 CleanupStack::PushL ( ret ); |
|
245 ret->ConstructL (); |
|
246 CleanupStack::Pop ( ret ); |
|
247 return ret; |
|
248 } |
|
249 |
|
250 CTcpClientTestUPnP16::CTcpClientTestUPnP16 ( CProxyProvd* aProvd ) : |
|
251 CTcpClientTestBase(aProvd), iTestServer(NULL) |
|
252 { |
|
253 } |
|
254 |
|
255 CTcpClientTestUPnP16::~CTcpClientTestUPnP16 () |
|
256 { |
|
257 iTimer.Close (); |
|
258 delete iCodec; |
|
259 iStringPool.Close(); |
|
260 delete iTransaction; |
|
261 delete iTestServer; |
|
262 delete iClientHandler; |
|
263 } |
|
264 |
|
265 void CTcpClientTestUPnP16::ConstructL() |
|
266 { |
|
267 iTimer.CreateLocal (); |
|
268 iStringPool.OpenL( TUPnPTable::Table() ); |
|
269 iStringPool.OpenL(THTTPTable::Table()); |
|
270 iCodec = CHeaderCodecPlugin::NewL ( KUPnPCodecName, iStringPool ); |
|
271 } |
|
272 |
|
273 TVerdict CTcpClientTestUPnP16::RunTestL() |
|
274 { |
|
275 switch ( iState ) |
|
276 { |
|
277 case ECreateTestServer: |
|
278 { |
|
279 iLogger.WriteFormat(_L("<i>Creating TestServer..... </i>")); |
|
280 |
|
281 iTestServer = CTestTcpServer::NewL ( *this ); |
|
282 |
|
283 iState = ECreateTestClient; |
|
284 iStatus = KRequestPending; |
|
285 Reschedule(); |
|
286 return EPass; |
|
287 } |
|
288 |
|
289 case ECreateTestClient: |
|
290 { |
|
291 iLogger.WriteFormat(_L("<i>TestServer is created..... </i>")); |
|
292 iLogger.WriteFormat(_L("<i>Creating TestClient..... </i>")); |
|
293 |
|
294 |
|
295 TInetAddr remoteAddress( KInetAddrLoop, 80 ); |
|
296 iClientHandler = CHTTPClientHandler::NewL ( *this, iChunkManager, &remoteAddress ); |
|
297 iClientHandler->SetConnectionInfo ( remoteAddress ); |
|
298 iTransaction = PrepareTransactionL (); |
|
299 iClientHandler->SubmitTransaction( iTransaction ); |
|
300 |
|
301 iState = ESendRequestData; |
|
302 iStatus = KRequestPending; |
|
303 Reschedule(); |
|
304 return EPass; |
|
305 } |
|
306 |
|
307 case ESendRequestData: |
|
308 { |
|
309 iClientHandler->SubmitTransaction( iTransaction ); |
|
310 iClientHandler->CancelTransaction( iTransaction ); |
|
311 |
|
312 delete iClientHandler; |
|
313 |
|
314 TInetAddr remoteAddress( KInetAddrLoop, 80 ); |
|
315 iClientHandler = CHTTPClientHandler::NewL ( *this, iChunkManager, &remoteAddress ); |
|
316 iTransaction->SetComposingStarted ( EFalse ); |
|
317 iClientHandler->SubmitTransaction( iTransaction ); |
|
318 iClientHandler->CancelTransaction( iTransaction ); |
|
319 |
|
320 iTimer.After ( iStatus, 60000000 ); //10 secs |
|
321 |
|
322 iState = EComplete; |
|
323 Reschedule(); |
|
324 |
|
325 return EPass; |
|
326 } |
|
327 |
|
328 case EComplete: |
|
329 { |
|
330 iLogger.WriteFormat(_L("<i>TestCase: Complete..... </i>")); |
|
331 return EPass; |
|
332 } |
|
333 |
|
334 default: |
|
335 iLogger.WriteFormat(_L("<i> Failed: TestCase:..... </i>")); |
|
336 ASSERT(0); |
|
337 return EFail; |
|
338 } |
|
339 } |
|
340 |
|
341 |
|
342 CHTTPClientTransaction* CTcpClientTestUPnP16::PrepareTransactionL () |
|
343 { |
|
344 TNodeCtxId channelId ( MeshMachine::KActivityNull, TNodeId::NullId() ); |
|
345 |
|
346 CHTTPClientTransaction* ctrans = CHTTPClientTransaction::NewL ( *iCodec, iStringPool, channelId ); |
|
347 |
|
348 CRequest* crequest = ctrans->Request( ); |
|
349 RHTTPHeaders headers = crequest->Handle( ).GetHeaderCollection ( ); |
|
350 RRequest rrequest = crequest->Handle( ); |
|
351 |
|
352 // Set request method |
|
353 RStringF stringF = iStringPool.StringF ( HTTP::EGET, THTTPTable::Table() ); |
|
354 rrequest.SetMethod ( stringF ); |
|
355 |
|
356 // Set request Uri |
|
357 TUriParser8 uriPath; |
|
358 uriPath.Parse ( _L8 ("/") ); |
|
359 rrequest.SetURIL ( uriPath ); |
|
360 |
|
361 RStringF hostValStr = iStringPool.OpenFStringL( _L8("127.0.0.1:80")); |
|
362 THTTPHdrVal hostVal ( hostValStr ); |
|
363 headers.SetFieldL ( iStringPool.StringF ( HTTP::EHost, THTTPTable::Table() ), hostVal ); |
|
364 hostValStr.Close (); |
|
365 |
|
366 ctrans->SetComplete (); |
|
367 |
|
368 stringF.Close (); |
|
369 return ctrans; |
|
370 } |
|
371 |
|
372 |
|
373 void CTcpClientTestUPnP16::OnTestServerEventL ( TInt aError ) |
|
374 { |
|
375 CompleteSelf ( aError ); |
|
376 } |
|
377 |
|
378 MTcpClientTestCase* CTcpClientTestUPnP16::GetTestCase () |
|
379 { |
|
380 return this; |
|
381 } |
|
382 |
|
383 CTestExecuteLogger& CTcpClientTestUPnP16::GetLogger ( ) |
|
384 { |
|
385 return iLogger; |
|
386 } |
|
387 |
|
388 |
|
389 const TDesC& CTcpClientTestUPnP16::TestCaseName () const |
|
390 { |
|
391 _LIT ( KTxtTitle, "Defect Fix CINC077703More" ); |
|
392 return KTxtTitle (); |
|
393 } |
|
394 |
|
395 TInt CTcpClientTestUPnP16::TotalTransactionCount () const |
|
396 { |
|
397 return KTransactionCount; |
|
398 } |
|
399 |
|
400 const TDesC8& CTcpClientTestUPnP16::GetRawRequest ( TInt aTransIndex ) |
|
401 { |
|
402 __ASSERT_ALWAYS ( aTransIndex < KTransactionCount, User::Invariant () ); |
|
403 return KTxtRawRequest1 (); |
|
404 } |
|
405 |
|
406 const TDesC8& CTcpClientTestUPnP16::GetRawResponse ( TInt aTransIndex ) |
|
407 { |
|
408 __ASSERT_ALWAYS( aTransIndex < KTransactionCount, User::Invariant () ); |
|
409 return KTxtRawResponse1 (); |
|
410 } |
|
411 |
|
412 TInt CTcpClientTestUPnP16::TransactionCount () const |
|
413 { |
|
414 return KTransactionCount; |
|
415 } |
|
416 |
|
417 |
|
418 TInt CTcpClientTestUPnP16::OnHttpEvent ( CTransaction* /*aTransaction*/, THTTPEvent& aEvent ) |
|
419 { |
|
420 if ( aEvent.iStatus == THTTPEvent::EResponseComplete ) |
|
421 { |
|
422 CompleteSelf ( KErrNone ); |
|
423 } |
|
424 else if ( aEvent.iStatus < 0 ) |
|
425 { |
|
426 CompleteSelf ( aEvent.iStatus ); |
|
427 } |
|
428 return KErrNone; |
|
429 } |
|
430 |
|
431 |
|
432 ///////////////////////////////////////////////////////////////////////////////////////////////// |
|
433 |
|
434 _LIT8 ( KBodyData1, "12345678901234567890" ); |
|
435 |
|
436 CTcpClientTestUPnP17* CTcpClientTestUPnP17::NewL ( CProxyProvd* aProvd ) |
|
437 { |
|
438 CTcpClientTestUPnP17* ret = new ( ELeave ) CTcpClientTestUPnP17 ( aProvd ); |
|
439 CleanupStack::PushL ( ret ); |
|
440 ret->ConstructL (); |
|
441 CleanupStack::Pop ( ret ); |
|
442 return ret; |
|
443 } |
|
444 |
|
445 CTcpClientTestUPnP17::CTcpClientTestUPnP17 ( CProxyProvd* aProvd ) : |
|
446 CTcpClientTestBase(aProvd), iTestServer(NULL) |
|
447 { |
|
448 } |
|
449 |
|
450 CTcpClientTestUPnP17::~CTcpClientTestUPnP17 () |
|
451 { |
|
452 iTimer.Close (); |
|
453 delete iCodec; |
|
454 iStringPool.Close(); |
|
455 delete iTransaction; |
|
456 delete iTestServer; |
|
457 delete iClientHandler; |
|
458 } |
|
459 |
|
460 void CTcpClientTestUPnP17::ConstructL() |
|
461 { |
|
462 iTimer.CreateLocal (); |
|
463 iStringPool.OpenL( TUPnPTable::Table() ); |
|
464 iStringPool.OpenL(THTTPTable::Table()); |
|
465 iCodec = CHeaderCodecPlugin::NewL ( KUPnPCodecName, iStringPool ); |
|
466 } |
|
467 |
|
468 TVerdict CTcpClientTestUPnP17::RunTestL() |
|
469 { |
|
470 switch ( iState ) |
|
471 { |
|
472 case ECreateTestServer: |
|
473 { |
|
474 iLogger.WriteFormat(_L("<i>Creating TestServer..... </i>")); |
|
475 |
|
476 iTestServer = CTestTcpServer::NewL ( *this ); |
|
477 |
|
478 iState = ECreateTestClient; |
|
479 iStatus = KRequestPending; |
|
480 Reschedule(); |
|
481 return EPass; |
|
482 } |
|
483 |
|
484 case ECreateTestClient: |
|
485 { |
|
486 iLogger.WriteFormat(_L("<i>TestServer is created..... </i>")); |
|
487 iLogger.WriteFormat(_L("<i>Creating TestClient..... </i>")); |
|
488 |
|
489 |
|
490 TInetAddr remoteAddress( KInetAddrLoop, 80 ); |
|
491 iClientHandler = CHTTPClientHandler::NewL ( *this, iChunkManager, &remoteAddress ); |
|
492 iClientHandler->SetConnectionInfo ( remoteAddress ); |
|
493 iTransaction = PrepareTransactionL (); |
|
494 iClientHandler->SubmitTransaction( iTransaction ); |
|
495 |
|
496 iState = EComplete; |
|
497 iStatus = KRequestPending; |
|
498 Reschedule(); |
|
499 return EPass; |
|
500 } |
|
501 |
|
502 case EComplete: |
|
503 { |
|
504 iLogger.WriteFormat(_L("<i>TestCase: Complete..... </i>")); |
|
505 return EPass; |
|
506 } |
|
507 |
|
508 default: |
|
509 iLogger.WriteFormat(_L("<i> Failed: TestCase:..... </i>")); |
|
510 ASSERT(0); |
|
511 return EFail; |
|
512 } |
|
513 } |
|
514 |
|
515 |
|
516 CHTTPClientTransaction* CTcpClientTestUPnP17::PrepareTransactionL () |
|
517 { |
|
518 TNodeCtxId channelId ( MeshMachine::KActivityNull, TNodeId::NullId() ); |
|
519 |
|
520 CHTTPClientTransaction* ctrans = CHTTPClientTransaction::NewL ( *iCodec, iStringPool, channelId ); |
|
521 |
|
522 CRequest* crequest = ctrans->Request( ); |
|
523 RHTTPHeaders headers = crequest->Handle( ).GetHeaderCollection ( ); |
|
524 RRequest rrequest = crequest->Handle( ); |
|
525 |
|
526 // Set request method |
|
527 RStringF stringF = iStringPool.StringF ( HTTP::EGET, THTTPTable::Table() ); |
|
528 rrequest.SetMethod ( stringF ); |
|
529 |
|
530 // Set request Uri |
|
531 TUriParser8 uriPath; |
|
532 uriPath.Parse ( _L8 ("/") ); |
|
533 rrequest.SetURIL ( uriPath ); |
|
534 |
|
535 RStringF hostValStr = iStringPool.OpenFStringL( _L8("127.0.0.1:80")); |
|
536 THTTPHdrVal hostVal ( hostValStr ); |
|
537 headers.SetFieldL ( iStringPool.StringF ( HTTP::EHost, THTTPTable::Table() ), hostVal ); |
|
538 hostValStr.Close (); |
|
539 |
|
540 //Set Content Length |
|
541 THTTPHdrVal hdrVal ( 10 ); |
|
542 headers.SetFieldL ( iStringPool.StringF ( HTTP::EContentLength, THTTPTable::Table() ), hdrVal ); |
|
543 |
|
544 stringF = iStringPool.StringF ( HTTP::E100Continue, THTTPTable::Table() ); |
|
545 |
|
546 // Set Body Data |
|
547 RMBufChain buf; |
|
548 buf.CreateL( KBodyData1); |
|
549 ctrans->AddBodyPart( buf ); |
|
550 ctrans->SetComplete (); |
|
551 |
|
552 stringF.Close (); |
|
553 return ctrans; |
|
554 } |
|
555 |
|
556 |
|
557 void CTcpClientTestUPnP17::OnTestServerEventL ( TInt aError ) |
|
558 { |
|
559 CompleteSelf ( aError ); |
|
560 } |
|
561 |
|
562 MTcpClientTestCase* CTcpClientTestUPnP17::GetTestCase () |
|
563 { |
|
564 return this; |
|
565 } |
|
566 |
|
567 CTestExecuteLogger& CTcpClientTestUPnP17::GetLogger ( ) |
|
568 { |
|
569 return iLogger; |
|
570 } |
|
571 |
|
572 |
|
573 const TDesC& CTcpClientTestUPnP17::TestCaseName () const |
|
574 { |
|
575 _LIT ( KTxtTitle, "CTcpClientTestUPnP17" ); |
|
576 return KTxtTitle (); |
|
577 } |
|
578 |
|
579 TInt CTcpClientTestUPnP17::TotalTransactionCount () const |
|
580 { |
|
581 return KTransactionCount; |
|
582 } |
|
583 |
|
584 const TDesC8& CTcpClientTestUPnP17::GetRawRequest ( TInt aTransIndex ) |
|
585 { |
|
586 __ASSERT_ALWAYS ( aTransIndex < KTransactionCount, User::Invariant () ); |
|
587 return KTxtRawRequest1 (); |
|
588 } |
|
589 |
|
590 const TDesC8& CTcpClientTestUPnP17::GetRawResponse ( TInt aTransIndex ) |
|
591 { |
|
592 __ASSERT_ALWAYS( aTransIndex < KTransactionCount, User::Invariant () ); |
|
593 return KTxtRawResponse1 (); |
|
594 } |
|
595 |
|
596 TInt CTcpClientTestUPnP17::TransactionCount () const |
|
597 { |
|
598 return KTransactionCount; |
|
599 } |
|
600 |
|
601 |
|
602 TInt CTcpClientTestUPnP17::OnHttpEvent ( CTransaction* /*aTransaction*/, THTTPEvent& aEvent ) |
|
603 { |
|
604 if ( aEvent.iStatus == THTTPEvent::EResponseComplete ) |
|
605 { |
|
606 CompleteSelf ( KErrNone ); |
|
607 } |
|
608 else if ( aEvent.iStatus < 0 ) |
|
609 { |
|
610 CompleteSelf ( aEvent.iStatus ); |
|
611 } |
|
612 return KErrNone; |
|
613 } |
|
614 |