diff --git a/src/storage/plugins/CurlStorage.cxx b/src/storage/plugins/CurlStorage.cxx index cc65badfd..e7a149d01 100644 --- a/src/storage/plugins/CurlStorage.cxx +++ b/src/storage/plugins/CurlStorage.cxx @@ -150,41 +150,6 @@ private: } }; -/** - * A helper class which feeds a (foreign) memory buffer into the - * CURLOPT_READFUNCTION. - */ -class CurlRequestBody { - ConstBuffer data; - -public: - explicit CurlRequestBody(ConstBuffer _data) - :data(ConstBuffer::FromVoid(_data)) {} - - explicit constexpr CurlRequestBody(StringView _data) - :data(_data) {} - - template - CurlRequestBody(CurlRequest &request, T _data) - :CurlRequestBody(_data) { - request.SetOption(CURLOPT_READFUNCTION, Callback); - request.SetOption(CURLOPT_READDATA, this); - } - -private: - size_t Read(char *buffer, size_t size) { - size_t n = std::min(size, data.size); - std::copy_n(data.begin(), n, buffer); - return n; - } - - static size_t Callback(char *buffer, size_t size, size_t nitems, - void *instream) { - auto &rb = *(CurlRequestBody *)instream; - return rb.Read(buffer, size * nitems); - } -}; - /** * The (relevant) contents of a "" element. */ @@ -253,7 +218,6 @@ ParseU64(const char *s, size_t length) */ class PropfindOperation : BlockingHttpRequest, CommonExpatParser { CurlSlist request_headers; - CurlRequestBody request_body; enum class State { ROOT, @@ -270,13 +234,7 @@ class PropfindOperation : BlockingHttpRequest, CommonExpatParser { public: PropfindOperation(CurlGlobal &_curl, const char *_uri, unsigned depth) :BlockingHttpRequest(_curl, _uri), - CommonExpatParser(ExpatNamespaceSeparator{'|'}), - request_body(request, - "\n" - "" - "" - "" - "") + CommonExpatParser(ExpatNamespaceSeparator{'|'}) { request.SetOption(CURLOPT_CUSTOMREQUEST, "PROPFIND"); @@ -286,6 +244,13 @@ public: request.SetOption(CURLOPT_HTTPHEADER, request_headers.Get()); + request.SetOption(CURLOPT_POSTFIELDS, + "\n" + "" + "" + "" + ""); + // TODO: send request body }