curl/Request: move struct Pause to class CurlResponseHandler
This commit is contained in:
parent
5d7ff150dd
commit
1e3089ffb7
@ -309,7 +309,7 @@ CurlInputStream::OnData(ConstBuffer<void> data)
|
|||||||
|
|
||||||
if (data.size > GetBufferSpace()) {
|
if (data.size > GetBufferSpace()) {
|
||||||
AsyncInputStream::Pause();
|
AsyncInputStream::Pause();
|
||||||
throw CurlRequest::Pause();
|
throw CurlResponseHandler::Pause{};
|
||||||
}
|
}
|
||||||
|
|
||||||
AppendToBuffer(data.data, data.size);
|
AppendToBuffer(data.data, data.size);
|
||||||
|
@ -43,6 +43,13 @@
|
|||||||
*/
|
*/
|
||||||
class CurlResponseHandler {
|
class CurlResponseHandler {
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* OnData() shall throw this to pause the stream. Call
|
||||||
|
* CurlEasy::Unpause() or CurlRequest::Resume() to resume the
|
||||||
|
* transfer.
|
||||||
|
*/
|
||||||
|
struct Pause {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Status line and headers have been received.
|
* Status line and headers have been received.
|
||||||
*/
|
*/
|
||||||
@ -51,6 +58,8 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Response body data has been received.
|
* Response body data has been received.
|
||||||
|
*
|
||||||
|
* May throw #Pause.
|
||||||
*/
|
*/
|
||||||
virtual void OnData(ConstBuffer<void> data) = 0;
|
virtual void OnData(ConstBuffer<void> data) = 0;
|
||||||
|
|
||||||
|
@ -241,7 +241,7 @@ CurlRequest::DataReceived(const void *ptr, size_t received_size) noexcept
|
|||||||
FinishHeaders();
|
FinishHeaders();
|
||||||
handler.OnData({ptr, received_size});
|
handler.OnData({ptr, received_size});
|
||||||
return received_size;
|
return received_size;
|
||||||
} catch (Pause) {
|
} catch (CurlResponseHandler::Pause) {
|
||||||
return CURL_WRITEFUNC_PAUSE;
|
return CURL_WRITEFUNC_PAUSE;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
state = State::CLOSED;
|
state = State::CLOSED;
|
||||||
|
@ -146,12 +146,6 @@ public:
|
|||||||
easy.SetRequestBody(data, size);
|
easy.SetRequestBody(data, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* CurlResponseHandler::OnData() shall throw this to pause the
|
|
||||||
* stream. Call Resume() to resume the transfer.
|
|
||||||
*/
|
|
||||||
struct Pause {};
|
|
||||||
|
|
||||||
void Resume() noexcept;
|
void Resume() noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user