Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
opendht
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
opendht
Commits
2a5f786f
Commit
2a5f786f
authored
5 years ago
by
Seva
Committed by
Adrien Béraud
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
http: handle request error codes through terminate
parent
c690d060
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/http.cpp
+7
-23
7 additions, 23 deletions
src/http.cpp
with
7 additions
and
23 deletions
src/http.cpp
+
7
−
23
View file @
2a5f786f
...
@@ -707,8 +707,10 @@ Request::connect(std::vector<asio::ip::tcp::endpoint>&& endpoints, HandlerCb cb)
...
@@ -707,8 +707,10 @@ Request::connect(std::vector<asio::ip::tcp::endpoint>&& endpoints, HandlerCb cb)
// try to connect to any until one works
// try to connect to any until one works
conn_
->
async_connect
(
std
::
move
(
endpoints
),
[
this
,
cb
]
conn_
->
async_connect
(
std
::
move
(
endpoints
),
[
this
,
cb
]
(
const
asio
::
error_code
&
ec
,
const
asio
::
ip
::
tcp
::
endpoint
&
endpoint
){
(
const
asio
::
error_code
&
ec
,
const
asio
::
ip
::
tcp
::
endpoint
&
endpoint
){
if
(
ec
==
asio
::
error
::
operation_aborted
)
if
(
ec
==
asio
::
error
::
operation_aborted
){
terminate
(
ec
);
return
;
return
;
}
else
if
(
ec
and
logger_
)
else
if
(
ec
and
logger_
)
logger_
->
e
(
"[http:client] [request:%i] connect: failed with all endpoints"
,
id_
);
logger_
->
e
(
"[http:client] [request:%i] connect: failed with all endpoints"
,
id_
);
else
{
else
{
...
@@ -757,9 +759,7 @@ Request::send()
...
@@ -757,9 +759,7 @@ Request::send()
}
}
else
if
(
!
conn_
or
!
conn_
->
is_open
()){
else
if
(
!
conn_
or
!
conn_
->
is_open
()){
connect
(
std
::
move
(
endpoints
),
[
this
](
const
asio
::
error_code
&
ec
){
connect
(
std
::
move
(
endpoints
),
[
this
](
const
asio
::
error_code
&
ec
){
if
(
ec
==
asio
::
error
::
operation_aborted
)
if
(
ec
)
return
;
else
if
(
ec
)
terminate
(
asio
::
error
::
not_connected
);
terminate
(
asio
::
error
::
not_connected
);
else
else
post
();
post
();
...
@@ -822,9 +822,7 @@ Request::terminate(const asio::error_code& ec)
...
@@ -822,9 +822,7 @@ Request::terminate(const asio::error_code& ec)
void
void
Request
::
handle_request
(
const
asio
::
error_code
&
ec
)
Request
::
handle_request
(
const
asio
::
error_code
&
ec
)
{
{
if
(
ec
==
asio
::
error
::
operation_aborted
)
if
(
ec
and
ec
!=
asio
::
error
::
eof
){
return
;
else
if
(
ec
and
ec
!=
asio
::
error
::
eof
){
terminate
(
ec
);
terminate
(
ec
);
return
;
return
;
}
}
...
@@ -843,13 +841,7 @@ Request::handle_request(const asio::error_code& ec)
...
@@ -843,13 +841,7 @@ Request::handle_request(const asio::error_code& ec)
void
void
Request
::
handle_response_header
(
const
asio
::
error_code
&
ec
)
Request
::
handle_response_header
(
const
asio
::
error_code
&
ec
)
{
{
if
(
ec
==
asio
::
error
::
operation_aborted
)
if
(
ec
&&
ec
!=
asio
::
error
::
eof
){
return
;
else
if
((
ec
==
asio
::
error
::
eof
)
or
(
ec
==
asio
::
error
::
connection_reset
)){
terminate
(
ec
);
return
;
}
else
if
((
ec
==
asio
::
error
::
eof
)
||
(
ec
==
asio
::
error
::
connection_reset
)){
terminate
(
ec
);
terminate
(
ec
);
return
;
return
;
}
}
...
@@ -901,15 +893,7 @@ Request::handle_response_header(const asio::error_code& ec)
...
@@ -901,15 +893,7 @@ Request::handle_response_header(const asio::error_code& ec)
void
void
Request
::
handle_response_body
(
const
asio
::
error_code
&
ec
,
const
size_t
bytes
)
Request
::
handle_response_body
(
const
asio
::
error_code
&
ec
,
const
size_t
bytes
)
{
{
if
(
ec
==
asio
::
error
::
operation_aborted
){
if
(
ec
&&
ec
!=
asio
::
error
::
eof
){
terminate
(
ec
);
return
;
}
else
if
((
ec
==
asio
::
error
::
eof
)
or
(
ec
==
asio
::
error
::
connection_reset
)){
terminate
(
ec
);
return
;
}
else
if
(
ec
&&
ec
!=
asio
::
error
::
eof
){
terminate
(
ec
);
terminate
(
ec
);
return
;
return
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment