curl/Request: move struct Pause to class CurlResponseHandler

This commit is contained in:
Max Kellermann 2020-12-11 14:04:16 +01:00 committed by Max Kellermann
parent 5d7ff150dd
commit 1e3089ffb7
4 changed files with 11 additions and 8 deletions

View File

@ -309,7 +309,7 @@ CurlInputStream::OnData(ConstBuffer<void> data)
if (data.size > GetBufferSpace()) {
AsyncInputStream::Pause();
throw CurlRequest::Pause();
throw CurlResponseHandler::Pause{};
}
AppendToBuffer(data.data, data.size);

View File

@ -43,6 +43,13 @@
*/
class CurlResponseHandler {
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.
*/
@ -51,6 +58,8 @@ public:
/**
* Response body data has been received.
*
* May throw #Pause.
*/
virtual void OnData(ConstBuffer<void> data) = 0;

View File

@ -241,7 +241,7 @@ CurlRequest::DataReceived(const void *ptr, size_t received_size) noexcept
FinishHeaders();
handler.OnData({ptr, received_size});
return received_size;
} catch (Pause) {
} catch (CurlResponseHandler::Pause) {
return CURL_WRITEFUNC_PAUSE;
} catch (...) {
state = State::CLOSED;

View File

@ -146,12 +146,6 @@ public:
easy.SetRequestBody(data, size);
}
/**
* CurlResponseHandler::OnData() shall throw this to pause the
* stream. Call Resume() to resume the transfer.
*/
struct Pause {};
void Resume() noexcept;
/**