merge with master
[framework/osp/net.git] / src / http / FNetHttp_HttpTransactionEvent.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file                FNetHttp_HttpTransactionEvent.cpp
20  * @brief               This is the implementation file for _HttpTransactionEvent class.
21  */
22
23 #include <FNetHttpIHttpTransactionEventListener.h>
24 #include <FNetHttpHttpRequest.h>
25 #include <FNetHttpHttpResponse.h>
26 #include <FBaseSysLog.h>
27 #include <FBaseRtIEventArg.h>
28 #include "FNetHttp_HttpSessionImpl.h"
29 #include "FNetHttp_HttpTransactionImpl.h"
30 #include "FNetHttp_HttpTransactionUserData.h"
31 #include "FNetHttp_HttpRequestImpl.h"
32 #include "FNetHttp_HttpResponseImpl.h"
33 #include "FNetHttp_HttpTransactionEvent.h"
34 #include "FNetHttp_HttpTransactionEventArg.h"
35
36 using namespace Tizen::Base;
37 using namespace Tizen::Base::Runtime;
38
39 namespace Tizen { namespace Net { namespace Http
40 {
41
42 _HttpTransactionEvent::_HttpTransactionEvent(void)
43         : __pHttpSessionImpl(null)
44         , __pHttpTransactionImpl(null)
45         , __pHttpProgressListener(null)
46         , __transactionId(-1)
47         , __isCertRequestedResult(false)
48 {
49 }
50
51 _HttpTransactionEvent::~_HttpTransactionEvent(void)
52 {
53         __pHttpSessionImpl = null;
54         __pHttpTransactionImpl = null;
55 }
56
57 result
58 _HttpTransactionEvent::Construct(_HttpSessionImpl* pHttpSessionImpl, _HttpTransactionImpl* pHttpTransactionImpl)
59 {
60         result r = E_SUCCESS;
61
62         SysTryReturnResult(NID_NET_HTTP, pHttpSessionImpl != null,
63                                            E_SYSTEM, "pHttpSessionImpl must not be null.");
64
65         SysTryReturnResult(NID_NET_HTTP, pHttpTransactionImpl != null,
66                                            E_SYSTEM, "pHttpTransactionImpl must not be null.");
67
68         __pHttpSessionImpl = pHttpSessionImpl;
69         __pHttpTransactionImpl = pHttpTransactionImpl;
70         __transactionId = pHttpTransactionImpl->GetTransactionId();
71
72         r = _Event::Initialize();
73
74         return r;
75 }
76
77 result
78 _HttpTransactionEvent::SetHttpProgressListener(const IHttpProgressEventListener* pListener)
79 {
80         result r = E_SUCCESS;
81
82         __pHttpProgressListener = const_cast< IHttpProgressEventListener* >(pListener);
83
84         return r;
85 }
86
87 bool
88 _HttpTransactionEvent::GetCertRequestedResult(void) const
89 {
90         return __isCertRequestedResult;
91 }
92
93 _HttpSessionImpl*
94 _HttpTransactionEvent::GetHttpSessionImpl(void) const
95 {
96         return __pHttpSessionImpl;
97 }
98
99 result
100 _HttpTransactionEvent::FireTransactionReadyToReadEvent(int readBodyLength, bool async)
101 {
102         result r = E_SUCCESS;
103
104         SysLog(NID_NET_HTTP, "Fire the event(_HTTP_TRANSACTION_EVENT_TYPE_READY_TO_READ), readBodyLength(%d), async(%d)", readBodyLength, async);
105
106         _HttpTransactionEventArg* pEventArg = new (std::nothrow) _HttpTransactionEventArg(__transactionId, _HTTP_TRANSACTION_EVENT_TYPE_READY_TO_READ);
107         SysTryReturnResult(NID_NET_HTTP, pEventArg != null,
108                                            E_OUT_OF_MEMORY, "Memory allocation failed.");
109
110         pEventArg->SetReadBodyLength(readBodyLength);
111
112         if (async)
113         {
114                 FireAsync(*pEventArg);
115         }
116         else
117         {
118                 Fire(*pEventArg);
119         }
120
121         return r;
122 }
123
124 result
125 _HttpTransactionEvent::FireTransactionReadyToWriteEvent(int recommenedLength, bool async)
126 {
127         result r = E_SUCCESS;
128
129         SysLog(NID_NET_HTTP, "Fire the event(_HTTP_TRANSACTION_EVENT_TYPE_READY_TO_WRITE), recommenedLength(%d), async(%d)", recommenedLength, async);
130
131         _HttpTransactionEventArg* pEventArg = new (std::nothrow) _HttpTransactionEventArg(__transactionId, _HTTP_TRANSACTION_EVENT_TYPE_READY_TO_WRITE);
132         SysTryReturnResult(NID_NET_HTTP, pEventArg != null,
133                                            E_OUT_OF_MEMORY, "Memory allocation failed.");
134
135         pEventArg->SetRecommendedSize(recommenedLength);
136
137         if (async)
138         {
139                 FireAsync(*pEventArg);
140         }
141         else
142         {
143                 Fire(*pEventArg);
144         }
145
146         return r;
147 }
148
149 result
150 _HttpTransactionEvent::FireTransactionHeaderCompletedEvent(int headerLength, long proxyAuth, long httpAuth, bool async)
151 {
152         result r = E_SUCCESS;
153
154         SysLog(NID_NET_HTTP, "Fire the event(_HTTP_TRANSACTION_EVENT_TYPE_HEADER_COMPLETED) HtpAuth(%ld), ProxyAuth(%ld), async(%d)", httpAuth, proxyAuth, async);
155
156         _HttpTransactionEventArg* pEventArg = new (std::nothrow) _HttpTransactionEventArg(__transactionId, _HTTP_TRANSACTION_EVENT_TYPE_HEADER_COMPLETED);
157         SysTryReturnResult(NID_NET_HTTP, pEventArg != null,
158                                            E_OUT_OF_MEMORY, "Memory allocation failed.");
159
160         pEventArg->SetReadHeaderLength(headerLength);
161
162         if (proxyAuth != _CURL_HTTP_AUTH_NONE)
163                 pEventArg->SetProxyAuth(true);
164
165         pEventArg->SetAuthType(httpAuth);
166
167         if (async)
168         {
169                 FireAsync(*pEventArg);
170         }
171         else
172         {
173                 Fire(*pEventArg);
174         }
175
176         return r;
177 }
178
179 result
180 _HttpTransactionEvent::FireTransactionCertVerificationRequiredNEvent(String* pServerCert, bool async)
181 {
182         result r = E_SUCCESS;
183
184         SysLog(NID_NET_HTTP, "Fire the event(_HTTP_TRANSACTION_EVENT_TYPE_CERT_VERIFICATION_REQUIRED), async(%d)", async);
185
186         _HttpTransactionEventArg* pEventArg = new (std::nothrow) _HttpTransactionEventArg(__transactionId, _HTTP_TRANSACTION_EVENT_TYPE_CERT_VERIFICATION_REQUIRED);
187         SysTryReturnResult(NID_NET_HTTP, pEventArg != null,
188                                            E_OUT_OF_MEMORY, "Memory allocation failed.");
189
190         pEventArg->SetServerCert(pServerCert);
191
192         if (async)
193         {
194                 FireAsync(*pEventArg);
195         }
196         else
197         {
198                 Fire(*pEventArg);
199         }
200
201         return r;
202 }
203
204 result
205 _HttpTransactionEvent::FireTransactionCertVerificationRequestedNEvent(Tizen::Base::Collection::IList* pServerCertList, bool async)
206 {
207         result r = E_SUCCESS;
208
209         SysLog(NID_NET_HTTP, "Fire the event(_HTTP_TRANSACTION_EVENT_TYPE_CERT_VERIFICATION_REQUESTED), async(%d)", async);
210
211         _HttpTransactionEventArg* pEventArg = new (std::nothrow) _HttpTransactionEventArg(__transactionId, _HTTP_TRANSACTION_EVENT_TYPE_CERT_VERIFICATION_REQUESTED);
212         SysTryReturnResult(NID_NET_HTTP, pEventArg != null,
213                                            E_OUT_OF_MEMORY, "Memory allocation failed.");
214
215         pEventArg->SetServerCertList(pServerCertList);
216
217         if (async)
218         {
219                 FireAsync(*pEventArg);
220         }
221         else
222         {
223                 Fire(*pEventArg);
224         }
225
226         return r;
227
228 }
229
230 result
231 _HttpTransactionEvent::FireTransactionCompletedEvent(bool async)
232 {
233         result r = E_SUCCESS;
234
235         SysLog(NID_NET_HTTP, "Fire the event(_HTTP_TRANSACTION_EVENT_TYPE_COMPLETD), async(%d)", async);
236
237         _HttpTransactionEventArg* pEventArg = new (std::nothrow) _HttpTransactionEventArg(__transactionId, _HTTP_TRANSACTION_EVENT_TYPE_COMPLETD);
238         SysTryReturnResult(NID_NET_HTTP, pEventArg != null,
239                                            E_OUT_OF_MEMORY, "Memory allocation failed.");
240
241         if (async)
242         {
243                 FireAsync(*pEventArg);
244         }
245         else
246         {
247                 Fire(*pEventArg);
248         }
249
250         return r;
251 }
252
253 result
254 _HttpTransactionEvent::FireTransactionAbortedEvent(result error, bool async)
255 {
256         result r = E_SUCCESS;
257
258         SysLog(NID_NET_HTTP, "Fire the event(_HTTP_TRANSACTION_EVENT_TYPE_ABORTED), error(%s), async(%d)", GetErrorMessage(error), async);
259
260         _HttpTransactionEventArg* pEventArg = new (std::nothrow) _HttpTransactionEventArg(__transactionId, _HTTP_TRANSACTION_EVENT_TYPE_ABORTED);
261         SysTryReturnResult(NID_NET_HTTP, pEventArg != null,
262                                            E_OUT_OF_MEMORY, "Memory allocation failed.");
263
264         pEventArg->SetError(error);
265
266         if (async)
267         {
268                 FireAsync(*pEventArg);
269         }
270         else
271         {
272                 Fire(*pEventArg);
273         }
274
275         return r;
276 }
277
278 result
279 _HttpTransactionEvent::FireHttpUploadInProgressEvent(int currentLength, int totalLength, bool async)
280 {
281         result r = E_SUCCESS;
282
283         SysLog(NID_NET_HTTP, "Fire the event(_HTTP_TRANSACTION_EVENT_TYPE_UPLOAD_PROGRESS), async(%d)", async);
284
285         _HttpTransactionEventArg* pEventArg = new (std::nothrow) _HttpTransactionEventArg(__transactionId, _HTTP_TRANSACTION_EVENT_TYPE_UPLOAD_PROGRESS);
286         SysTryReturnResult(NID_NET_HTTP, pEventArg != null,
287                                            E_OUT_OF_MEMORY, "Memory allocation failed.");
288
289         pEventArg->SetUploadProgress(currentLength, totalLength);
290
291         if (async)
292         {
293                 FireAsync(*pEventArg);
294         }
295         else
296         {
297                 Fire(*pEventArg);
298         }
299
300         return r;
301 }
302
303 result
304 _HttpTransactionEvent::FireHttpDownloadInProgressEvent(int currentLength, int totalLength, bool async)
305 {
306         result r = E_SUCCESS;
307
308         SysLog(NID_NET_HTTP, "Fire the event(_HTTP_TRANSACTION_EVENT_TYPE_DOWNLOAD_PROGRESS), async(%d)", async);
309
310         _HttpTransactionEventArg* pEventArg = new (std::nothrow) _HttpTransactionEventArg(__transactionId, _HTTP_TRANSACTION_EVENT_TYPE_DOWNLOAD_PROGRESS);
311         SysTryReturnResult(NID_NET_HTTP, pEventArg != null,
312                                            E_OUT_OF_MEMORY, "Memory allocation failed.");
313
314         pEventArg->SetDownloadProgress(currentLength, totalLength);
315
316         if (async)
317         {
318                 FireAsync(*pEventArg);
319         }
320         else
321         {
322                 Fire(*pEventArg);
323         }
324
325         return r;
326 }
327
328 void
329 _HttpTransactionEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
330 {
331         result r = E_SUCCESS;
332
333         HttpSession* pHttpSessoin = null;
334         HttpTransaction* pHttpTransaction = null;
335         _HttpTransactionUserData* pHttpTransactionUserData = null;
336
337         _HttpRequestImpl* pHttpRequestImpl = null;
338         IHttpEntity* pIHttpEntity = null;
339         _HttpResponseImpl* pHttpResponseImpl = null;
340         IHttpTransactionEventListener* pHttpTransactionEventListener = null;
341         IEventArg* pEventArg = null;
342         _HttpTransactionEventArg* pHttpTransactionEventArg = null;
343
344         bool isAuthRequired = false;
345         int readHeaderLength = 0;
346         long httpAuth = 0;
347         bool isProxyAuth = false;
348         int readBodyLength = 0;
349         int recommendedSize = 0;
350
351         long long currentUploadProgress = 0;
352         long long totalUploadProgress = 0;
353         long long currentDownloadProgress = 0;
354         long long totalDownloadProgress = 0;
355
356         int transactionId = -1;
357         _HttpTransactionEventType eventType = _HTTP_TRANSACTION_EVENT_TYPE_UNDEFINED;
358
359         SysLog(NID_NET_HTTP, "calling FireImpl.");
360
361         pEventArg = const_cast< IEventArg* >(&arg);
362         pHttpTransactionEventListener = dynamic_cast< IHttpTransactionEventListener* >(&listener);
363         SysTryReturnVoidResult(NID_NET_HTTP, pHttpTransactionEventListener != null, E_SYSTEM,
364                                                    "[E_SYSTEM] The event listener must not be null.");
365
366         pHttpTransactionEventArg = dynamic_cast< _HttpTransactionEventArg* >(pEventArg);
367         SysTryReturnVoidResult(NID_NET_HTTP, pHttpTransactionEventArg != null, E_SYSTEM,
368                                                    "[E_SYSTEM] The event argument must not be null.");
369
370         transactionId = pHttpTransactionEventArg->GetTransactionId();
371         eventType = pHttpTransactionEventArg->GetEventType();
372
373         pHttpSessoin = __pHttpSessionImpl->GetHttpSession();
374         pHttpTransaction = __pHttpTransactionImpl->GetHttpTransaction();
375
376         pHttpTransactionUserData = __pHttpTransactionImpl->GetHttpTransactionUserData();
377
378         SysLog(NID_NET_HTTP, "The event type is %s. HttpTransaction[%d]", _HttpUtility::ConvertHttpTransactionEventTypeToString(eventType), transactionId);
379
380         switch (eventType)
381         {
382         case _HTTP_TRANSACTION_EVENT_TYPE_UNDEFINED:
383
384                 r = E_SYSTEM;
385                 SysLogException(NID_NET_HTTP, r, "[E_SYSTEM] The NET_HTTP_TRANSACTION_EVENT_UNDEFINED must not be set.");
386
387                 break;
388
389         case _HTTP_TRANSACTION_EVENT_TYPE_HEADER_COMPLETED:
390
391                 pHttpResponseImpl = _HttpResponseImpl::GetInstance(*__pHttpTransactionImpl->GetResponse());
392                 r = pHttpResponseImpl->Read(pHttpTransactionEventArg->GetReadHeaderLength(), 0, readHeaderLength, readBodyLength);
393                 SysTryCatch(NID_NET_HTTP, r == E_SUCCESS, r = E_INVALID_CONTENT, E_INVALID_CONTENT,
394                                         "[E_INVALID_CONTENT] The header format is invalid.");
395
396                 SysLog(NID_NET_HTTP, "The value of GetReadHeaderLength() is %d, the readHeaderLength is %d.",
397                            pHttpTransactionEventArg->GetReadHeaderLength(), readHeaderLength);
398
399                 //if Http Status Code is 401 or 407
400                 if (pHttpResponseImpl->GetHttpStatusCode() == NET_HTTP_STATUS_UNAUTHORIZED || pHttpResponseImpl->GetHttpStatusCode() ==
401                         NET_HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED)
402                 {
403                         httpAuth = pHttpTransactionEventArg->GetAuthType();
404                         isProxyAuth = pHttpTransactionEventArg->IsProxyAuth();
405
406                         NetHttpAuthScheme authScheme = _HttpUtility::GetHttpAuthScheme(isProxyAuth, httpAuth);
407                         __pHttpTransactionImpl->SetHttpAuthType(authScheme);
408
409                         isAuthRequired = true;
410                         SysLog(NID_NET_HTTP, "The authScheme is %s.", _HttpUtility::GetHttpAuthSchemeByString(authScheme));
411                 }
412
413                 SysLog(NID_NET_HTTP, "####### Calling callback : OnTransactionHeaderCompleted(HeaderLength: %d, AuthRequired: %d, HttpTransaction[%d])",
414                            readHeaderLength, isAuthRequired, transactionId);
415                 pHttpTransactionEventListener->OnTransactionHeaderCompleted(*pHttpSessoin, *pHttpTransaction, readHeaderLength, isAuthRequired);
416                 SysLog(NID_NET_HTTP, "####### Called callback : OnTransactionHeaderCompleted");
417
418                 readHeaderLength = 0;
419                 readBodyLength = 0;
420
421                 break;
422
423         case _HTTP_TRANSACTION_EVENT_TYPE_READY_TO_READ:
424
425                 pHttpResponseImpl = _HttpResponseImpl::GetInstance(*__pHttpTransactionImpl->GetResponse());
426                 r = pHttpResponseImpl->Read(0, pHttpTransactionEventArg->GetReadBodyLength(), readHeaderLength, readBodyLength);
427                 SysTryCatch(NID_NET_HTTP, r == E_SUCCESS, r = E_INVALID_CONTENT, E_INVALID_CONTENT,
428                                         "[E_INVALID_CONTENT] The header format is invalid.");
429
430                 SysLog(NID_NET_HTTP, "####### Calling callback : OnTransactionReadyToRead(availableBodyLen: %d, HttpTransaction[%d])",
431                            readBodyLength, transactionId);
432                 pHttpTransactionEventListener->OnTransactionReadyToRead(*pHttpSessoin, *pHttpTransaction, readBodyLength);
433                 SysLog(NID_NET_HTTP, "####### Called callback : OnTransactionReadyToRead ");
434                 readHeaderLength = 0;
435                 readBodyLength = 0;
436
437                 break;
438
439         case _HTTP_TRANSACTION_EVENT_TYPE_READY_TO_WRITE:
440
441                 pHttpRequestImpl = _HttpRequestImpl::GetInstance(*__pHttpTransactionImpl->GetRequest());
442                 pIHttpEntity = pHttpRequestImpl->GetEntity();
443                 recommendedSize = pHttpTransactionEventArg->GetRecommendedSize();
444
445                 if (pIHttpEntity != null)
446                 {
447                         SysLog(NID_NET_HTTP, "####### Calling callback : [IHttpEntity] OnTransactionReadyToWrite(recommendedSize: %d, HttpTransaction[%d])",
448                                    recommendedSize, transactionId);
449
450                         if (pHttpRequestImpl->HasNextData())
451                         {
452                                 ByteBuffer* pBuffer = pHttpRequestImpl->GetNextDataN(recommendedSize);
453                                 r = GetLastResult();
454                                 r = TransExceptionsExclusive(r, E_IO, E_OUT_OF_MEMORY);
455                                 SysTryCatch(NID_NET_HTTP, r == E_SUCCESS, , r,
456                                                         "[%s] Failed to get the next data.", GetErrorMessage(r));
457
458                                 r = pHttpRequestImpl->WriteBody(*pBuffer);
459                                 delete pBuffer;
460                                 r = TransExceptionsExclusive(r, E_IO, E_OUT_OF_MEMORY);
461                                 SysTryCatch(NID_NET_HTTP, r == E_SUCCESS, , r,
462                                                         "[%s] Failed to write the next data.", GetErrorMessage(r));
463                         }
464                         else
465                         {
466                                 ByteBuffer lastChunk;
467                                 r = lastChunk.Construct(0);
468                                 SysTryCatch(NID_NET_HTTP, r == E_SUCCESS, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
469                                                         "[E_OUT_OF_MEMORY] Memory allocation failed.");
470
471                                 r = pHttpRequestImpl->WriteBody(lastChunk);
472                                 r = TransExceptionsExclusive(r, E_IO, E_OUT_OF_MEMORY);
473                                 SysTryCatch(NID_NET_HTTP, r == E_SUCCESS, , r,
474                                                         "[%s] Failed to write the last chunk.", GetErrorMessage(r));
475                         }
476
477                 }
478                 else
479                 {
480                         SysLog(NID_NET_HTTP, "####### Calling callback : OnTransactionReadyToWrite(recommendedSize: %d, HttpTransaction[%d])",
481                                    recommendedSize, transactionId);
482                         pHttpTransactionEventListener->OnTransactionReadyToWrite(*pHttpSessoin, *pHttpTransaction, recommendedSize);
483                         SysLog(NID_NET_HTTP, "####### Called callback : OnTransactionReadyToWrite");
484                 }
485
486                 break;
487
488         case _HTTP_TRANSACTION_EVENT_TYPE_COMPLETD:
489
490                 SysLog(NID_NET_HTTP, "####### Calling callback : OnTransactionCompleted(HttpTransaction[%d])", transactionId);
491                 pHttpTransactionEventListener->OnTransactionCompleted(*pHttpSessoin, *pHttpTransaction);
492                 SysLog(NID_NET_HTTP, "####### Called callback : OnTransactionCompleted");
493
494                 pHttpTransactionUserData->CloseTransaction();
495                 readHeaderLength = 0;
496                 readBodyLength = 0;
497
498                 break;
499
500         case _HTTP_TRANSACTION_EVENT_TYPE_ABORTED:
501
502                 SysLog(NID_NET_HTTP, "####### Calling callback : OnTransactionAborted(HttpTransaction(%s)[%d])", GetErrorMessage(pHttpTransactionEventArg->GetError()), transactionId);
503                 pHttpTransactionEventListener->OnTransactionAborted(*pHttpSessoin, *pHttpTransaction, pHttpTransactionEventArg->GetError());
504                 SysLog(NID_NET_HTTP, "####### Called callback : OnTransactionAborted");
505
506                 pHttpTransactionUserData->CloseTransaction();
507
508                 break;
509
510         case _HTTP_TRANSACTION_EVENT_TYPE_CERT_VERIFICATION_REQUIRED:
511
512                 SysLog(NID_NET_HTTP, "####### Calling callback : OnTransactionCertVerificationRequiredN(HttpTransaction[%d])", transactionId);
513                 __pHttpTransactionImpl->SetCertRequiredEventFired(true);
514                 pHttpTransactionEventListener->OnTransactionCertVerificationRequiredN(*pHttpSessoin, *pHttpTransaction, pHttpTransactionEventArg->GetServerCert());
515                 SysLog(NID_NET_HTTP, "####### Called callback : OnTransactionCertVerificationRequiredN");
516
517                 break;
518
519         case _HTTP_TRANSACTION_EVENT_TYPE_CERT_VERIFICATION_REQUESTED:
520
521                 SysLog(NID_NET_HTTP, "####### Calling callback : OnTransactionCertVerificationRequestedN(HttpTransaction[%d])", transactionId);
522                 __isCertRequestedResult = pHttpTransactionEventListener->OnTransactionCertVerificationRequestedN(*pHttpSessoin, *pHttpTransaction, pHttpTransactionEventArg->GetServerCertList());
523                 SysLog(NID_NET_HTTP, "####### Called callback : OnTransactionCertVerificationRequestedN(%d)", __isCertRequestedResult);
524
525                 break;
526
527         case _HTTP_TRANSACTION_EVENT_TYPE_UPLOAD_PROGRESS:
528
529                 currentUploadProgress = pHttpTransactionEventArg->GetCurrentUploadProgress();
530                 totalUploadProgress = pHttpTransactionEventArg->GetTotalUploadProgress();
531
532                 SysLog(NID_NET_HTTP, "####### Calling callback : OnHttpUploadInProgress(%lld/%lld, HttpTransaction[%d])",
533                            currentUploadProgress, totalUploadProgress, transactionId);
534                 __pHttpProgressListener->OnHttpUploadInProgress(*pHttpSessoin, *pHttpTransaction, currentUploadProgress, totalUploadProgress);
535                 SysLog(NID_NET_HTTP, "####### Called callback : OnHttpUploadInProgress");
536
537                 break;
538
539         case _HTTP_TRANSACTION_EVENT_TYPE_DOWNLOAD_PROGRESS:
540
541                 currentDownloadProgress = pHttpTransactionEventArg->GetCurrentDownloadProgress();
542                 totalDownloadProgress = pHttpTransactionEventArg->GetTotalDownloadProgress();
543
544                 SysLog(NID_NET_HTTP, "####### Calling callback : OnHttpDownloadInProgress(%lld/%lld, HttpTransaction[%d])",
545                            currentDownloadProgress, totalDownloadProgress, transactionId);
546                 __pHttpProgressListener->OnHttpDownloadInProgress(*pHttpSessoin, *pHttpTransaction, currentDownloadProgress, totalDownloadProgress);
547                 SysLog(NID_NET_HTTP, "####### Called callback : OnHttpDownloadInProgress");
548
549                 break;
550
551         default:
552                 r = E_SYSTEM;
553                 SysLogException(NID_NET_HTTP, r, "[E_SYSTEM] The eventType is invalid.");
554                 SysAssertf(false, "[E_SYSTEM] The eventType is invalid.");
555
556                 break;
557
558         }
559
560         SysLog(NID_NET_HTTP, "Called FireImpl.");
561
562         return;
563
564 CATCH:
565
566         SysLog(NID_NET_HTTP, "####### Calling callback : OnTransactionAborted(HttpTransaction[%d])", transactionId);
567         pHttpTransactionEventListener->OnTransactionAborted(*pHttpSessoin, *pHttpTransaction, r);
568         SysLog(NID_NET_HTTP, "####### Called callback : OnTransactionAborted");
569
570         pHttpTransactionUserData->CloseTransaction();
571
572         return;
573 }
574
575 } } } // Tizen::Net::Http