FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
easyhttpcpp/src/HttpAsyncExecutionTask.cpp at master · sony/easyhttpcpp · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
sony
/
easyhttpcpp
Public
Notifications
You must be signed in to change notification settings
Fork
31
Star
176
Code
Issues
11
Pull requests
1
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
easyhttpcpp
/
src
/
HttpAsyncExecutionTask.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
69 lines (56 loc) · 2.11 KB
Breadcrumbs
easyhttpcpp
/
src
/
HttpAsyncExecutionTask.cpp
Copy path
File metadata and controls
69 lines (56 loc) · 2.11 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
* Copyright 2017 Sony Corporation
*/
#
include
"
easyhttpcpp/common/CoreLogger.h
"
#
include
"
easyhttpcpp/HttpException.h
"
#
include
"
HttpAsyncExecutionTask.h
"
namespace
easyhttpcpp
{
static
const
std::string Tag =
"
HttpAsyncExecutionTask
"
;
HttpAsyncExecutionTask::HttpAsyncExecutionTask
(EasyHttpContext::Ptr pContext,
HttpRequestExecutor::Ptr pRequestExecutor, ResponseCallback::Ptr pResponseCallback) :
m_pContext
(pContext), m_pRequestExecutor(pRequestExecutor), m_pResponseCallback(pResponseCallback)
{
}
HttpAsyncExecutionTask::~HttpAsyncExecutionTask
()
{
}
void
HttpAsyncExecutionTask::runTask
()
{
Response::Ptr pResponse;
try
{
pResponse = m_pRequestExecutor->
execute
();
}
catch
(
const
HttpException& e) {
EASYHTTPCPP_LOG_D
(Tag,
"
Error while executing Http asynchronous request. Details: %s
"
, e.
getMessage
().
c_str
());
notifyCompletion
(e.
clone
(),
NULL
);
return
;
}
catch
(
const
std::exception& e) {
EASYHTTPCPP_LOG_D
(Tag,
"
Unexpected error while executing Http asynchronous request. Details: %s
"
, e.
what
());
HttpExecutionException::Ptr pWhat =
new
HttpExecutionException
(
"
Unexpected error while executing Http asynchronous request. Check getCause() for details.
"
, e);
notifyCompletion
(pWhat,
NULL
);
return
;
}
EASYHTTPCPP_LOG_D
(Tag,
"
Http asynchronous request succeeded.
"
);
notifyCompletion
(
NULL
, pResponse);
}
bool
HttpAsyncExecutionTask::cancel
(
bool
mayInterruptIfRunning)
{
return
m_pRequestExecutor->
cancel
();
}
bool
HttpAsyncExecutionTask::isCancelled
()
const
{
return
m_pRequestExecutor->
isCancelled
();
}
void
HttpAsyncExecutionTask::notifyCompletion
(HttpException::Ptr pWhat, Response::Ptr pResponse)
{
HttpExecutionTaskManager::Ptr pExecutionTaskManager = m_pContext->
getHttpExecutionTaskManager
();
pExecutionTaskManager->
onComplete
(
HttpExecutionTask::Ptr
(
this
,
true
));
if
(m_pResponseCallback) {
if
(pWhat) {
m_pResponseCallback->
onFailure
(pWhat);
}
else
{
m_pResponseCallback->
onResponse
(pResponse);
}
}
}
}
/*
namespace easyhttpcpp
*/
Back
|
FazBrowse Home
|
New Git URL