Merge branch 'v0.23.x'
This commit is contained in:
commit
af951dc08a
2
NEWS
2
NEWS
|
@ -15,6 +15,8 @@ ver 0.24 (not yet released)
|
|||
- GCC 10 or clang 11 (or newer) recommended
|
||||
|
||||
ver 0.23.8 (not yet released)
|
||||
* storage
|
||||
- curl: fix crash if web server does not understand WebDAV
|
||||
|
||||
ver 0.23.7 (2022/05/09)
|
||||
* database
|
||||
|
|
|
@ -85,6 +85,12 @@ CurlResponseHandlerAdapter::FinishBody()
|
|||
void
|
||||
CurlResponseHandlerAdapter::Done(CURLcode result) noexcept
|
||||
{
|
||||
if (postponed_error) {
|
||||
state = State::CLOSED;
|
||||
handler.OnError(std::move(postponed_error));
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (result != CURLE_OK) {
|
||||
StripRight(error_buffer);
|
||||
|
@ -174,6 +180,13 @@ CurlResponseHandlerAdapter::DataReceived(const void *ptr,
|
|||
return received_size;
|
||||
} catch (CurlResponseHandler::Pause) {
|
||||
return CURL_WRITEFUNC_PAUSE;
|
||||
} catch (...) {
|
||||
/* from inside this libCURL callback function, we
|
||||
can't do much, so we remember the exception to be
|
||||
handled later by Done(), and return 0, causing the
|
||||
response to be aborted with CURLE_WRITE_ERROR */
|
||||
postponed_error = std::current_exception();
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <curl/curl.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <exception>
|
||||
#include <string_view>
|
||||
|
||||
class CurlEasy;
|
||||
|
@ -46,6 +47,12 @@ class CurlResponseHandlerAdapter {
|
|||
|
||||
Curl::Headers headers;
|
||||
|
||||
/**
|
||||
* An exception caught from within the WriteFunction() which
|
||||
* will later be handled by Done().
|
||||
*/
|
||||
std::exception_ptr postponed_error;
|
||||
|
||||
/** error message provided by libcurl */
|
||||
char error_buffer[CURL_ERROR_SIZE];
|
||||
|
||||
|
|
|
@ -51,13 +51,19 @@ public:
|
|||
|
||||
/**
|
||||
* Status line and headers have been received.
|
||||
*
|
||||
* Exceptions thrown by this method will be passed to
|
||||
* OnError(), aborting the request.
|
||||
*/
|
||||
virtual void OnHeaders(unsigned status, Curl::Headers &&headers) = 0;
|
||||
|
||||
/**
|
||||
* Response body data has been received.
|
||||
*
|
||||
* May throw #Pause (but nothing else).
|
||||
* May throw #Pause.
|
||||
*
|
||||
* Other exceptions thrown by this method will be passed to
|
||||
* OnError(), aborting the request.
|
||||
*/
|
||||
virtual void OnData(std::span<const std::byte> data) = 0;
|
||||
|
||||
|
|
Loading…
Reference in New Issue