Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
1bab6d0d
Commit
1bab6d0d
authored
Jan 08, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib/curl/Request: move catch clause out of FinishHeaders
Let the caller decide what to do with the exception.
parent
13b85edb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
17 deletions
+12
-17
Request.cxx
src/lib/curl/Request.cxx
+11
-16
Request.hxx
src/lib/curl/Request.hxx
+1
-1
No files found.
src/lib/curl/Request.cxx
View file @
1bab6d0d
...
@@ -114,32 +114,24 @@ CurlRequest::Resume()
...
@@ -114,32 +114,24 @@ CurlRequest::Resume()
global
.
InvalidateSockets
();
global
.
InvalidateSockets
();
}
}
bool
void
CurlRequest
::
FinishHeaders
()
CurlRequest
::
FinishHeaders
()
{
{
if
(
state
!=
State
::
HEADERS
)
if
(
state
!=
State
::
HEADERS
)
return
true
;
return
;
state
=
State
::
BODY
;
state
=
State
::
BODY
;
long
status
=
0
;
long
status
=
0
;
curl_easy_getinfo
(
easy
.
Get
(),
CURLINFO_RESPONSE_CODE
,
&
status
);
curl_easy_getinfo
(
easy
.
Get
(),
CURLINFO_RESPONSE_CODE
,
&
status
);
try
{
handler
.
OnHeaders
(
status
,
std
::
move
(
headers
));
handler
.
OnHeaders
(
status
,
std
::
move
(
headers
));
return
true
;
}
catch
(...)
{
state
=
State
::
CLOSED
;
handler
.
OnError
(
std
::
current_exception
());
return
false
;
}
}
}
void
void
CurlRequest
::
FinishBody
()
CurlRequest
::
FinishBody
()
{
{
if
(
!
FinishHeaders
())
FinishHeaders
();
return
;
if
(
state
!=
State
::
BODY
)
if
(
state
!=
State
::
BODY
)
return
;
return
;
...
@@ -167,7 +159,12 @@ CurlRequest::Done(CURLcode result)
...
@@ -167,7 +159,12 @@ CurlRequest::Done(CURLcode result)
return
;
return
;
}
}
FinishBody
();
try
{
FinishBody
();
}
catch
(...)
{
state
=
State
::
CLOSED
;
handler
.
OnError
(
std
::
current_exception
());
}
}
}
inline
void
inline
void
...
@@ -221,10 +218,8 @@ CurlRequest::DataReceived(const void *ptr, size_t received_size)
...
@@ -221,10 +218,8 @@ CurlRequest::DataReceived(const void *ptr, size_t received_size)
{
{
assert
(
received_size
>
0
);
assert
(
received_size
>
0
);
if
(
!
FinishHeaders
())
return
0
;
try
{
try
{
FinishHeaders
();
handler
.
OnData
({
ptr
,
received_size
});
handler
.
OnData
({
ptr
,
received_size
});
return
received_size
;
return
received_size
;
}
catch
(
Pause
)
{
}
catch
(
Pause
)
{
...
...
src/lib/curl/Request.hxx
View file @
1bab6d0d
...
@@ -115,7 +115,7 @@ private:
...
@@ -115,7 +115,7 @@ private:
*/
*/
void
FreeEasy
();
void
FreeEasy
();
bool
FinishHeaders
();
void
FinishHeaders
();
void
FinishBody
();
void
FinishBody
();
size_t
DataReceived
(
const
void
*
ptr
,
size_t
size
);
size_t
DataReceived
(
const
void
*
ptr
,
size_t
size
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment