diff options
| author | Dan Engelbrecht <[email protected]> | 2024-01-31 10:31:00 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-01-31 10:31:00 +0100 |
| commit | 78968c2e97a5c407a65088aa9861052d80498053 (patch) | |
| tree | 4fa02e7b9fd0b321b8ed7e4adaa7e06c6527929c /src/zenhttp/httpclient.cpp | |
| parent | Update README.md (diff) | |
| download | zen-78968c2e97a5c407a65088aa9861052d80498053.tar.xz zen-78968c2e97a5c407a65088aa9861052d80498053.zip | |
improve oplog export logging (#644)
- Improvement: More details in oplog import/export logs
- Improvement: Switch from Download to Get when fetching Refs from Jupiter as they can't be resumed anyway and streaming to disk is redundant
- Bugfix: Make sure we clear read callback when doing Put in HttpClient to avoid timeout due to not sending data when reusing sessions
- Bugfix: Respect `--ignore-missing-attachments` in `oplog-export` command when loose file is missing on disk
Diffstat (limited to 'src/zenhttp/httpclient.cpp')
| -rw-r--r-- | src/zenhttp/httpclient.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/zenhttp/httpclient.cpp b/src/zenhttp/httpclient.cpp index c9005b1cf..cc8a3f033 100644 --- a/src/zenhttp/httpclient.cpp +++ b/src/zenhttp/httpclient.cpp @@ -210,10 +210,15 @@ struct HttpClient::Impl : public RefCounted ZEN_TRACE("HEAD {}", Result); return Result; } - inline cpr::Response Put() + inline cpr::Response Put(std::optional<cpr::ReadCallback>&& Read = {}) { + if (Read) + { + CprSession->SetReadCallback(std::move(Read.value())); + } cpr::Response Result = CprSession->Put(); ZEN_TRACE("PUT {}", Result); + CprSession->SetReadCallback({}); return Result; } inline cpr::Response Post() @@ -790,12 +795,9 @@ HttpClient::Upload(std::string_view Url, const IoBuffer& Payload, const KeyValue Offset += size; return true; }; - Sess->SetReadCallback(cpr::ReadCallback(gsl::narrow<cpr::cpr_off_t>(Payload.GetSize()), ReadCallback)); - } - else - { - Sess->SetBody(AsCprBody(Payload)); + return Sess.Put(cpr::ReadCallback(gsl::narrow<cpr::cpr_off_t>(Payload.GetSize()), ReadCallback)); } + Sess->SetBody(AsCprBody(Payload)); return Sess.Put(); }, m_ConnectionSettings.RetryCount)); @@ -821,9 +823,7 @@ HttpClient::Upload(std::string_view Url, const CompositeBuffer& Payload, ZenCont SizeLeft -= size; return true; }; - Sess->SetReadCallback(cpr::ReadCallback(gsl::narrow<cpr::cpr_off_t>(Payload.GetSize()), ReadCallback)); - - return Sess.Put(); + return Sess.Put(cpr::ReadCallback(gsl::narrow<cpr::cpr_off_t>(Payload.GetSize()), ReadCallback)); }, m_ConnectionSettings.RetryCount)); } |